summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Panteleev <github.private@thecybershadow.net>2018-03-18 05:20:04 +0100
committerDylan William Hardison <dylan@hardison.net>2018-03-18 05:20:04 +0100
commit9a9a5a5229f102fdb629029bed7a200cde6a5a68 (patch)
treeecdd76165ceef91ec7dbe0d83c6b8e6dfbd29cb1
parente42ef329ca55a269b1d33cc26ae37b68a18020ed (diff)
downloadbugzilla-9a9a5a5229f102fdb629029bed7a200cde6a5a68.tar.gz
bugzilla-9a9a5a5229f102fdb629029bed7a200cde6a5a68.tar.xz
Bug 1446236 - Bugzilla/Search.pm: Use Bugzilla::Extension::TrackingFlags only when present
-rw-r--r--Bugzilla/Search.pm28
1 files changed, 16 insertions, 12 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index f419955dc..643d591ca 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -34,6 +34,7 @@ use Date::Format;
use Date::Parse;
use Scalar::Util qw(blessed);
use List::MoreUtils qw(all firstidx part uniq);
+use List::Util qw(any);
use POSIX qw(INT_MAX);
use Storable qw(dclone);
use Time::HiRes qw(gettimeofday tv_interval);
@@ -802,18 +803,21 @@ sub data {
# BMO - to avoid massive amounts of joins, if we're selecting a lot of
# tracking flags, replace them with placeholders. the values will be
# retrieved later and injected into the result.
- my %tf_map = map { $_ => 1 } Bugzilla::Extension::TrackingFlags::Flag->get_all_names();
- my @tf_selected = grep { exists $tf_map{$_} } @orig_fields;
- # mysql has a limit of 61 joins, and we want to avoid massive amounts of joins
- # 30 ensures we won't hit the limit, nor generate too many joins
- if (scalar @tf_selected > 30) {
- foreach my $column (@tf_selected) {
- $self->COLUMNS->{$column}->{name} = "'---'";
+ state $have_tracking_flags = any { $_->NAME eq 'TrackingFlags' } @{ Bugzilla->extensions };
+ if ($have_tracking_flags) {
+ my %tf_map = map { $_ => 1 } Bugzilla::Extension::TrackingFlags::Flag->get_all_names();
+ my @tf_selected = grep { exists $tf_map{$_} } @orig_fields;
+ # mysql has a limit of 61 joins, and we want to avoid massive amounts of joins
+ # 30 ensures we won't hit the limit, nor generate too many joins
+ if (scalar @tf_selected > 30) {
+ foreach my $column (@tf_selected) {
+ $self->COLUMNS->{$column}->{name} = "'---'";
+ }
+ $self->{tracking_flags} = \@tf_selected;
+ }
+ else {
+ $self->{tracking_flags} = [];
}
- $self->{tracking_flags} = \@tf_selected;
- }
- else {
- $self->{tracking_flags} = [];
}
my $start_time = [gettimeofday()];
@@ -863,7 +867,7 @@ sub data {
$self->{data} = [map { $data{$_} } @$bug_ids];
# BMO - get tracking flags values, and insert into result
- if (@{ $self->{tracking_flags} }) {
+ if ($have_tracking_flags && @{ $self->{tracking_flags} }) {
# read values
my $values;
$sql = "