summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2012-12-19 09:56:47 +0100
committerByron Jones <bjones@mozilla.com>2012-12-19 09:56:47 +0100
commit387608caac85ccf6c0782572420ecbdae4e301bf (patch)
treea047006cbf485bb714dea61b39731e28a1366fca /Bugzilla
parente068bcc76fe842fbcac8249ed29593f8a17b0c24 (diff)
downloadbugzilla-387608caac85ccf6c0782572420ecbdae4e301bf.tar.gz
bugzilla-387608caac85ccf6c0782572420ecbdae4e301bf.tar.xz
Bug 815532: Add caching for Bugzilla::User objects
r=dkl,a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Attachment.pm5
-rw-r--r--Bugzilla/Bug.pm6
-rw-r--r--Bugzilla/Comment.pm3
-rw-r--r--Bugzilla/Component.pm17
-rw-r--r--Bugzilla/Flag.pm15
5 files changed, 18 insertions, 28 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm
index 3dbd4ce6d..3678424c9 100644
--- a/Bugzilla/Attachment.pm
+++ b/Bugzilla/Attachment.pm
@@ -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
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 1f2b3cfea..3506422ce 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -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'};
}
diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm
index caefb2d6d..0277819c4 100644
--- a/Bugzilla/Comment.pm
+++ b/Bugzilla/Comment.pm
@@ -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'};
}
diff --git a/Bugzilla/Component.pm b/Bugzilla/Component.pm
index 53a6f216c..3fb87de6f 100644
--- a/Bugzilla/Component.pm
+++ b/Bugzilla/Component.pm
@@ -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 {
diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm
index 9073d349e..3660e2a7f 100644
--- a/Bugzilla/Flag.pm
+++ b/Bugzilla/Flag.pm
@@ -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 });
}
################################