]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 815532: Add caching for Bugzilla::User objects
authorByron Jones <bjones@mozilla.com>
Wed, 19 Dec 2012 08:56:47 +0000 (16:56 +0800)
committerByron Jones <bjones@mozilla.com>
Wed, 19 Dec 2012 08:56:47 +0000 (16:56 +0800)
r=dkl,a=LpSolit

Bugzilla/Attachment.pm
Bugzilla/Bug.pm
Bugzilla/Comment.pm
Bugzilla/Component.pm
Bugzilla/Flag.pm

index 3dbd4ce6dab24a0ee547265e9ae1c37e2f2249b1..3678424c951c13b7a401d43a3f15c62f1a29fca0 100644 (file)
@@ -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
index 1f2b3cfeab79fce65bdd05f2372f06d49389db8c..3506422ce965ac2b8bfa3c1c84adaacad59d715c 100644 (file)
@@ -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'};
 }
 
index caefb2d6d28aad751bbacf2542c5598de2ad4735..0277819c4c4f05bdee7ea7c3c447b82de5509e20 100644 (file)
@@ -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'};
 }
 
index 53a6f216c86b2033691ec225ddf8c9709bfe0182..3fb87de6f5896ee2717fec21815a706b0995a256 100644 (file)
@@ -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 {
index 9073d349ed95b1afc7a4727a8770fc71bead6958..3660e2a7f143991cd17c2c590f1be933d332197e 100644 (file)
@@ -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 });
 }
 
 ################################