From 1c5e0c47c92128afebef5614407d84cd72c12b35 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Wed, 28 Nov 2012 16:40:21 +0800 Subject: Bug 814411: Add a caching mechanism to Bugzilla::Object to avoid querying the database repeatedly for the same information --- extensions/Splinter/Extension.pm | 2 +- extensions/Splinter/lib/Util.pm | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'extensions/Splinter') diff --git a/extensions/Splinter/Extension.pm b/extensions/Splinter/Extension.pm index 9c8be4beb..980ab0054 100644 --- a/extensions/Splinter/Extension.pm +++ b/extensions/Splinter/Extension.pm @@ -36,7 +36,7 @@ sub page_before_template { if ($input->{'bug'}) { $vars->{'bug_id'} = $input->{'bug'}; $vars->{'attach_id'} = $input->{'attachment'}; - $vars->{'bug'} = Bugzilla::Bug->check($input->{'bug'}); + $vars->{'bug'} = Bugzilla::Bug->check({ id => $input->{'bug'}, cache => 1 }); } if ($input->{'attachment'}) { diff --git a/extensions/Splinter/lib/Util.pm b/extensions/Splinter/lib/Util.pm index 6305395f9..9f09d3dcc 100644 --- a/extensions/Splinter/lib/Util.pm +++ b/extensions/Splinter/lib/Util.pm @@ -53,7 +53,8 @@ sub attachment_id_is_valid { detaint_natural($attach_id) || return 0; # Make sure the attachment exists in the database. - my $attachment = new Bugzilla::Attachment($attach_id) || return 0; + my $attachment = new Bugzilla::Attachment({ id => $attach_id, cache => 1 }) + || return 0; return $attachment if ($dont_validate_access || attachment_is_visible($attachment)); @@ -135,7 +136,7 @@ sub add_review_links_to_email { if ($email->header('Subject') =~ /^\[Bug\s+(\d+)\]/ && Bugzilla->user->can_see_bug($1)) { - $bug = Bugzilla::Bug->new($1); + $bug = Bugzilla::Bug->new({ id => $1, cache => 1 }); } return unless defined $bug; -- cgit v1.2.3-24-g4f1b