summaryrefslogtreecommitdiffstats
path: root/Bugzilla.pm
diff options
context:
space:
mode:
authorVladimir Panteleev <github.private@thecybershadow.net>2018-04-08 05:57:06 +0200
committerDylan William Hardison <dylan@hardison.net>2018-04-08 05:57:06 +0200
commitb0935c1e52eea1dfc70652bf6fcb7c8b856a8826 (patch)
tree2400c507178262779288c10ccdfc773d858da098 /Bugzilla.pm
parent2d80cea9010f694524f5d165a19697c47535d779 (diff)
downloadbugzilla-b0935c1e52eea1dfc70652bf6fcb7c8b856a8826.tar.gz
bugzilla-b0935c1e52eea1dfc70652bf6fcb7c8b856a8826.tar.xz
Bug 1446236 - Add & use simpler method to check if an extension is present (#35)
Diffstat (limited to 'Bugzilla.pm')
-rw-r--r--Bugzilla.pm20
1 files changed, 20 insertions, 0 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index e43110389..f5e64c371 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -233,6 +233,15 @@ sub template_inner {
sub extensions {
my ($class) = @_;
+
+ # Guard against extensions querying the extension list during initialization
+ # (through this method or has_extension).
+ # The extension list is not fully populated at that point,
+ # so the results would not be meaningful.
+ state $recursive = 0;
+ die "Recursive attempt to load/query extensions" if $recursive;
+ $recursive = 1;
+
my $cache = $class->request_cache;
if (!$cache->{extensions}) {
my $extension_packages = Bugzilla::Extension->load_all();
@@ -245,9 +254,20 @@ sub extensions {
}
$cache->{extensions} = \@extensions;
}
+ $recursive = 0;
return $cache->{extensions};
}
+sub has_extension {
+ my ($class, $name) = @_;
+ my $cache = $class->request_cache;
+ if (!$cache->{extensions_hash}) {
+ my %extensions = map { $_->NAME => 1 } @{ Bugzilla->extensions };
+ $cache->{extensions_hash} = \%extensions;
+ }
+ return exists $cache->{extensions_hash}{$name};
+}
+
sub cgi {
return $_[0]->request_cache->{cgi} ||= new Bugzilla::CGI();
}