File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -123,9 +123,19 @@ sub template_inner {
123
123
||= Bugzilla::Template-> create(%options );
124
124
}
125
125
126
+ our $in_extensions = 0;
127
+
126
128
sub extensions {
127
129
state $extensions ;
128
130
return $extensions if $extensions ;
131
+
132
+ # Guard against extensions querying the extension list during initialization
133
+ # (through this method or has_extension).
134
+ # The extension list is not fully populated at that point,
135
+ # so the results would not be meaningful.
136
+ die " Recursive attempt to load/query extensions" if $in_extensions > 0;
137
+ local $in_extensions = $in_extensions + 1;
138
+
129
139
my $extension_packages = Bugzilla::Extension-> load_all();
130
140
$extensions = [];
131
141
foreach my $package (@$extension_packages ) {
@@ -136,6 +146,16 @@ sub extensions {
136
146
return $extensions ;
137
147
}
138
148
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
+
139
159
sub cgi {
140
160
return request_cache-> {cgi } ||= Bugzilla::CGI-> new;
141
161
}
You can’t perform that action at this time.
0 commit comments