File tree Expand file tree Collapse file tree 4 files changed +23
-10
lines changed
Expand file tree Collapse file tree 4 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,14 @@ sub template_inner {
125125}
126126
127127sub extensions {
128+ # Guard against extensions querying the extension list during initialization
129+ # (through this method or has_extension).
130+ # The extension list is not fully populated at that point,
131+ # so the results would not be meaningful.
132+ state $recursive = 0;
133+ die " Recursive attempt to load/query extensions" if $recursive ;
134+ $recursive = 1;
135+
128136 state $extensions ;
129137 return $extensions if $extensions ;
130138 my $extension_packages = Bugzilla::Extension-> load_all();
@@ -134,9 +142,20 @@ sub extensions {
134142 push @$extensions , $package ;
135143 }
136144 }
145+ $recursive = 0;
137146 return $extensions ;
138147}
139148
149+ sub has_extension {
150+ my ($class , $name ) = @_ ;
151+ my $cache = $class -> request_cache;
152+ if (!$cache -> {extensions_hash }) {
153+ my %extensions = map { $_ -> NAME => 1 } @{Bugzilla-> extensions};
154+ $cache -> {extensions_hash } = \%extensions ;
155+ }
156+ return exists $cache -> {extensions_hash }{$name };
157+ }
158+
140159sub cgi {
141160 return request_cache-> {cgi } ||= Bugzilla::CGI-> new;
142161}
Original file line number Diff line number Diff line change @@ -34,7 +34,6 @@ use Date::Format;
3434use Date::Parse;
3535use Scalar::Util qw( blessed) ;
3636use List::MoreUtils qw( all firstidx part uniq) ;
37- use List::Util qw( any) ;
3837use POSIX qw( INT_MAX) ;
3938use Storable qw( dclone) ;
4039use Time::HiRes qw( gettimeofday tv_interval) ;
@@ -803,9 +802,7 @@ sub data {
803802 # BMO - to avoid massive amounts of joins, if we're selecting a lot of
804803 # tracking flags, replace them with placeholders. the values will be
805804 # retrieved later and injected into the result.
806- state $have_tracking_flags
807- = any { $_ -> NAME eq ' TrackingFlags' } @{Bugzilla-> extensions};
808- if ($have_tracking_flags ) {
805+ if (Bugzilla-> has_extension(' TrackingFlags' )) {
809806 my %tf_map = map { $_ => 1 } Bugzilla-> tracking_flag_names;
810807 my @tf_selected = grep { exists $tf_map {$_ } } @orig_fields ;
811808
@@ -874,7 +871,7 @@ sub data {
874871 $self -> {data } = [map { $data {$_ } } @$bug_ids ];
875872
876873 # BMO - get tracking flags values, and insert into result
877- if ($have_tracking_flags && @{$self -> {tracking_flags }}) {
874+ if (Bugzilla -> has_extension( ' TrackingFlags ' ) && @{$self -> {tracking_flags }}) {
878875
879876 # read values
880877 my $values ;
Original file line number Diff line number Diff line change @@ -197,9 +197,7 @@ sub template_before_process {
197197 return if exists $bug -> {error };
198198
199199 # trigger loading of tracking flags
200- state $have_tracking_flags
201- = any { $_ -> NAME eq ' TrackingFlags' } @{Bugzilla-> extensions};
202- if ($have_tracking_flags ) {
200+ if (Bugzilla-> has_extension(' TrackingFlags' )) {
203201 Bugzilla::Extension::TrackingFlags-> template_before_process({
204202 file => ' bug/edit.html.tmpl' , vars => $vars ,
205203 });
Original file line number Diff line number Diff line change @@ -30,8 +30,7 @@ use lib qw(. lib local/lib/perl5);
3030use Bugzilla;
3131use Bugzilla::Error;
3232
33- my $is_enabled = grep { $_ -> NAME eq ' Voting' } @{Bugzilla-> extensions};
34- $is_enabled || ThrowCodeError(' extension_disabled' , {name => ' Voting' });
33+ Bugzilla-> has_extension(' Voting' ) || ThrowCodeError(' extension_disabled' , { name => ' Voting' });
3534
3635my $cgi = Bugzilla-> cgi;
3736my $action = $cgi -> param(' action' ) || ' show_user' ;
You can’t perform that action at this time.
0 commit comments