Commit 387608ca authored by Byron Jones's avatar Byron Jones

Bug 815532: Add caching for Bugzilla::User objects

r=dkl,a=LpSolit
parent e068bcc7
...@@ -190,9 +190,8 @@ the user who attached the attachment ...@@ -190,9 +190,8 @@ the user who attached the attachment
sub attacher { sub attacher {
my $self = shift; my $self = shift;
return $self->{attacher} if exists $self->{attacher}; return $self->{attacher}
$self->{attacher} = new Bugzilla::User($self->{submitter_id}); ||= new Bugzilla::User({ id => $self->{submitter_id}, cache => 1 });
return $self->{attacher};
} }
=over =over
......
...@@ -3154,7 +3154,7 @@ sub assigned_to { ...@@ -3154,7 +3154,7 @@ sub assigned_to {
my ($self) = @_; my ($self) = @_;
return $self->{'assigned_to_obj'} if exists $self->{'assigned_to_obj'}; return $self->{'assigned_to_obj'} if exists $self->{'assigned_to_obj'};
$self->{'assigned_to'} = 0 if $self->{'error'}; $self->{'assigned_to'} = 0 if $self->{'error'};
$self->{'assigned_to_obj'} ||= new Bugzilla::User($self->{'assigned_to'}); $self->{'assigned_to_obj'} ||= new Bugzilla::User({ id => $self->{'assigned_to'}, cache => 1 });
return $self->{'assigned_to_obj'}; return $self->{'assigned_to_obj'};
} }
...@@ -3452,7 +3452,7 @@ sub qa_contact { ...@@ -3452,7 +3452,7 @@ sub qa_contact {
return undef if $self->{'error'}; return undef if $self->{'error'};
if (Bugzilla->params->{'useqacontact'} && $self->{'qa_contact'}) { if (Bugzilla->params->{'useqacontact'} && $self->{'qa_contact'}) {
$self->{'qa_contact_obj'} = new Bugzilla::User($self->{'qa_contact'}); $self->{'qa_contact_obj'} = new Bugzilla::User({ id => $self->{'qa_contact'}, cache => 1 });
} else { } else {
$self->{'qa_contact_obj'} = undef; $self->{'qa_contact_obj'} = undef;
} }
...@@ -3463,7 +3463,7 @@ sub reporter { ...@@ -3463,7 +3463,7 @@ sub reporter {
my ($self) = @_; my ($self) = @_;
return $self->{'reporter'} if exists $self->{'reporter'}; return $self->{'reporter'} if exists $self->{'reporter'};
$self->{'reporter_id'} = 0 if $self->{'error'}; $self->{'reporter_id'} = 0 if $self->{'error'};
$self->{'reporter'} = new Bugzilla::User($self->{'reporter_id'}); $self->{'reporter'} = new Bugzilla::User({ id => $self->{'reporter_id'}, cache => 1 });
return $self->{'reporter'}; return $self->{'reporter'};
} }
......
...@@ -137,7 +137,8 @@ sub attachment { ...@@ -137,7 +137,8 @@ sub attachment {
sub author { sub author {
my $self = shift; my $self = shift;
$self->{'author'} ||= new Bugzilla::User($self->{'who'}); $self->{'author'}
||= new Bugzilla::User({ id => $self->{'who'}, cache => 1 });
return $self->{'author'}; return $self->{'author'};
} }
......
...@@ -342,23 +342,16 @@ sub bug_ids { ...@@ -342,23 +342,16 @@ sub bug_ids {
sub default_assignee { sub default_assignee {
my $self = shift; my $self = shift;
if (!defined $self->{'default_assignee'}) { return $self->{'default_assignee'}
$self->{'default_assignee'} = ||= new Bugzilla::User({ id => $self->{'initialowner'}, cache => 1 });
new Bugzilla::User($self->{'initialowner'});
}
return $self->{'default_assignee'};
} }
sub default_qa_contact { sub default_qa_contact {
my $self = shift; my $self = shift;
return if !$self->{'initialqacontact'}; return unless $self->{'initialqacontact'};
return $self->{'default_qa_contact'}
if (!defined $self->{'default_qa_contact'}) { ||= new Bugzilla::User({id => $self->{'initialqacontact'}, cache => 1 });
$self->{'default_qa_contact'} =
new Bugzilla::User($self->{'initialqacontact'});
}
return $self->{'default_qa_contact'};
} }
sub flag_types { sub flag_types {
......
...@@ -181,22 +181,20 @@ is an attachment flag, else undefined. ...@@ -181,22 +181,20 @@ is an attachment flag, else undefined.
sub type { sub type {
my $self = shift; my $self = shift;
$self->{'type'} ||= new Bugzilla::FlagType($self->{'type_id'}); return $self->{'type'} ||= new Bugzilla::FlagType($self->{'type_id'});
return $self->{'type'};
} }
sub setter { sub setter {
my $self = shift; my $self = shift;
$self->{'setter'} ||= new Bugzilla::User($self->{'setter_id'}); return $self->{'setter'} ||= new Bugzilla::User({ id => $self->{'setter_id'}, cache => 1 });
return $self->{'setter'};
} }
sub requestee { sub requestee {
my $self = shift; my $self = shift;
if (!defined $self->{'requestee'} && $self->{'requestee_id'}) { if (!defined $self->{'requestee'} && $self->{'requestee_id'}) {
$self->{'requestee'} = new Bugzilla::User($self->{'requestee_id'}); $self->{'requestee'} = new Bugzilla::User({ id => $self->{'requestee_id'}, cache => 1 });
} }
return $self->{'requestee'}; return $self->{'requestee'};
} }
...@@ -206,16 +204,15 @@ sub attachment { ...@@ -206,16 +204,15 @@ sub attachment {
return undef unless $self->attach_id; return undef unless $self->attach_id;
require Bugzilla::Attachment; require Bugzilla::Attachment;
$self->{'attachment'} ||= new Bugzilla::Attachment($self->attach_id); return $self->{'attachment'}
return $self->{'attachment'}; ||= new Bugzilla::Attachment({ id => $self->attach_id, cache => 1 });
} }
sub bug { sub bug {
my $self = shift; my $self = shift;
require Bugzilla::Bug; require Bugzilla::Bug;
$self->{'bug'} ||= new Bugzilla::Bug($self->bug_id); return $self->{'bug'} ||= new Bugzilla::Bug({ id => $self->bug_id, cache => 1 });
return $self->{'bug'};
} }
################################ ################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment