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
sub attacher {
my $self = shift;
return $self->{attacher} if exists $self->{attacher};
$self->{attacher} = new Bugzilla::User($self->{submitter_id});
return $self->{attacher};
return $self->{attacher}
||= new Bugzilla::User({ id => $self->{submitter_id}, cache => 1 });
}
=over
......
......@@ -3154,7 +3154,7 @@ sub assigned_to {
my ($self) = @_;
return $self->{'assigned_to_obj'} if exists $self->{'assigned_to_obj'};
$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'};
}
......@@ -3452,7 +3452,7 @@ sub qa_contact {
return undef if $self->{'error'};
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 {
$self->{'qa_contact_obj'} = undef;
}
......@@ -3463,7 +3463,7 @@ sub reporter {
my ($self) = @_;
return $self->{'reporter'} if exists $self->{'reporter'};
$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'};
}
......
......@@ -137,7 +137,8 @@ sub attachment {
sub author {
my $self = shift;
$self->{'author'} ||= new Bugzilla::User($self->{'who'});
$self->{'author'}
||= new Bugzilla::User({ id => $self->{'who'}, cache => 1 });
return $self->{'author'};
}
......
......@@ -342,23 +342,16 @@ sub bug_ids {
sub default_assignee {
my $self = shift;
if (!defined $self->{'default_assignee'}) {
$self->{'default_assignee'} =
new Bugzilla::User($self->{'initialowner'});
}
return $self->{'default_assignee'};
return $self->{'default_assignee'}
||= new Bugzilla::User({ id => $self->{'initialowner'}, cache => 1 });
}
sub default_qa_contact {
my $self = shift;
return if !$self->{'initialqacontact'};
if (!defined $self->{'default_qa_contact'}) {
$self->{'default_qa_contact'} =
new Bugzilla::User($self->{'initialqacontact'});
}
return $self->{'default_qa_contact'};
return unless $self->{'initialqacontact'};
return $self->{'default_qa_contact'}
||= new Bugzilla::User({id => $self->{'initialqacontact'}, cache => 1 });
}
sub flag_types {
......
......@@ -181,22 +181,20 @@ is an attachment flag, else undefined.
sub type {
my $self = shift;
$self->{'type'} ||= new Bugzilla::FlagType($self->{'type_id'});
return $self->{'type'};
return $self->{'type'} ||= new Bugzilla::FlagType($self->{'type_id'});
}
sub setter {
my $self = shift;
$self->{'setter'} ||= new Bugzilla::User($self->{'setter_id'});
return $self->{'setter'};
return $self->{'setter'} ||= new Bugzilla::User({ id => $self->{'setter_id'}, cache => 1 });
}
sub requestee {
my $self = shift;
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'};
}
......@@ -206,16 +204,15 @@ sub attachment {
return undef unless $self->attach_id;
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 {
my $self = shift;
require Bugzilla::Bug;
$self->{'bug'} ||= new Bugzilla::Bug($self->bug_id);
return $self->{'bug'};
return $self->{'bug'} ||= new Bugzilla::Bug({ id => $self->bug_id, cache => 1 });
}
################################
......
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