summaryrefslogtreecommitdiffstats
path: root/Bugzilla.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla.pm')
-rw-r--r--Bugzilla.pm50
1 files changed, 32 insertions, 18 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index 44286c75b..3ba535c8e 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -13,7 +13,7 @@ use warnings;
use Bugzilla::Logging;
-our $VERSION = '20180820.1';
+our $VERSION = '5.16';
use Bugzilla::Auth;
use Bugzilla::Auth::Persist::Cookie;
@@ -46,6 +46,7 @@ use File::Basename;
use File::Spec::Functions;
use Safe;
use JSON::XS qw(decode_json);
+use URI;
use Scope::Guard;
use parent qw(Bugzilla::CPAN);
@@ -114,20 +115,6 @@ sub init_page {
# 001compile.t test).
return if $^C;
- # IIS prints out warnings to the webpage, so ignore them, or log them
- # to a file if the file exists.
- if ($ENV{SERVER_SOFTWARE} && $ENV{SERVER_SOFTWARE} =~ /microsoft-iis/i) {
- $SIG{__WARN__} = sub {
- my ($msg) = @_;
- my $datadir = bz_locations()->{'datadir'};
- if (-w "$datadir/errorlog") {
- my $warning_log = new IO::File(">>$datadir/errorlog");
- print $warning_log $msg;
- $warning_log->close();
- }
- };
- }
-
my $script = basename($0);
# Because of attachment_base, attachment.cgi handles this itself.
@@ -223,6 +210,14 @@ sub template_inner {
}
sub extensions {
+ # 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 = request_cache;
if (!$cache->{extensions}) {
my $extension_packages = Bugzilla::Extension->load_all();
@@ -235,9 +230,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 request_cache->{cgi} ||= Bugzilla::CGI->new;
}
@@ -262,6 +268,13 @@ sub localconfig {
return $_[0]->process_cache->{localconfig} ||= read_localconfig();
}
+sub urlbase {
+ my ($class) = @_;
+
+ # Since this could be modified, we have to return a new one every time.
+ return URI->new($class->localconfig->{urlbase});
+}
+
sub params {
return request_cache->{params} ||= Bugzilla::Config::read_param_file();
}
@@ -838,7 +851,7 @@ sub check_rate_limit {
my $limit = join("/", @$limit);
Bugzilla->audit("[rate_limit] action=$action, ip=$ip, limit=$limit, name=$name");
if ($action eq 'block') {
- Bugzilla::ModPerl::BlockIP->block_ip($ip);
+ $Bugzilla::Quantum::CGI::C->block_ip($ip);
ThrowUserError("rate_limit");
}
}
@@ -854,6 +867,7 @@ sub markdown_parser {
# Per-process cleanup. Note that this is a plain subroutine, not a method,
# so we don't have $class available.
+*cleanup = \&_cleanup;
sub _cleanup {
return if $^C;
@@ -880,10 +894,10 @@ sub _cleanup {
sub END {
# Bugzilla.pm cannot compile in mod_perl.pl if this runs.
- _cleanup() unless $ENV{MOD_PERL};
+ _cleanup() unless BZ_PERSISTENT;
}
-init_page() if !$ENV{MOD_PERL};
+init_page() unless BZ_PERSISTENT;
1;