summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2013-08-12 17:27:34 +0200
committerDave Lawrence <dlawrence@mozilla.com>2013-08-12 17:27:34 +0200
commitafa23774e953411a0b7ad73739970d5b81495195 (patch)
treee8b1c7beaaab36caf5b464b082993184b0d06f5e /Bugzilla
parent8adaad7fda9776639d06f97703e2984e376232dc (diff)
downloadbugzilla-afa23774e953411a0b7ad73739970d5b81495195.tar.gz
bugzilla-afa23774e953411a0b7ad73739970d5b81495195.tar.xz
Bug 899537 - backport upstream bug 897029 to bmo/4.2 for performance improvement
r=glob
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/User.pm8
-rw-r--r--Bugzilla/WebService/Bug.pm6
2 files changed, 14 insertions, 0 deletions
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index bd7c8123b..f1803ac79 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -892,6 +892,14 @@ sub visible_bugs {
if (@check_ids) {
my $dbh = Bugzilla->dbh;
my $user_id = $self->id;
+
+ foreach my $id (@check_ids) {
+ my $orig_id = $id;
+ detaint_natural($id)
+ || ThrowCodeError('param_must_be_numeric', { param => $orig_id,
+ function => 'Bugzilla::User->visible_bugs'});
+ }
+
my $sth;
# Speed up the can_see_bug case.
if (scalar(@check_ids) == 1) {
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index df9084210..34c16f99f 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -330,6 +330,12 @@ sub get {
my @bugs;
my @faults;
+
+ # Cache permissions for bugs. This highly reduces the number of calls to the DB.
+ # visible_bugs() is only able to handle bug IDs, so we have to skip aliases.
+ my @int = grep { $_ =~ /^\d+$/ } @$ids;
+ Bugzilla->user->visible_bugs(\@int);
+
foreach my $bug_id (@$ids) {
my $bug;
if ($params->{permissive}) {