aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mod_perl.pl')
-rw-r--r--mod_perl.pl97
1 files changed, 50 insertions, 47 deletions
diff --git a/mod_perl.pl b/mod_perl.pl
index 80dff2304..642a92149 100644
--- a/mod_perl.pl
+++ b/mod_perl.pl
@@ -31,18 +31,19 @@ use lib Bugzilla::Constants::bz_locations()->{'ext_libpath'};
use Apache2::Log ();
use Apache2::ServerUtil;
use ModPerl::RegistryLoader ();
-use File::Basename ();
-use DateTime ();
+use File::Basename ();
+use DateTime ();
# This loads most of our modules.
use Bugzilla ();
+
# Loading Bugzilla.pm doesn't load this, though, and we want it preloaded.
-use Bugzilla::BugMail ();
-use Bugzilla::CGI ();
-use Bugzilla::Extension ();
+use Bugzilla::BugMail ();
+use Bugzilla::CGI ();
+use Bugzilla::Extension ();
use Bugzilla::Install::Requirements ();
-use Bugzilla::Util ();
-use Bugzilla::RNG ();
+use Bugzilla::Util ();
+use Bugzilla::RNG ();
# Make warnings go to the virtual host's log and not the main
# server log.
@@ -52,6 +53,7 @@ BEGIN { *CORE::GLOBAL::warn = \&Apache2::ServerRec::warn; }
Bugzilla::CGI->compile(qw(:cgi :push));
use Apache2::SizeLimit;
+
# This means that every httpd child will die after processing
# a CGI if it is taking up more than 45MB of RAM all by itself,
# not counting RAM it is sharing with the other httpd processes.
@@ -62,7 +64,7 @@ my $cgi_path = Bugzilla::Constants::bz_locations()->{'cgi_path'};
# Set up the configuration for the web server
my $server = Apache2::ServerUtil->server;
-my $conf = <<EOT;
+my $conf = <<EOT;
# Make sure each httpd child receives a different random seed (bug 476622).
# Bugzilla::RNG has one srand that needs to be called for
# every process, and Perl has another. (Various Perl modules still use
@@ -88,7 +90,8 @@ $Bugzilla::extension_packages = Bugzilla::Extension->load_all();
# Have ModPerl::RegistryLoader pre-compile all CGI scripts.
my $rl = new ModPerl::RegistryLoader();
-# If we try to do this in "new" it fails because it looks for a
+
+# If we try to do this in "new" it fails because it looks for a
# Bugzilla/ModPerl/ResponseHandler.pm
$rl->{package} = 'Bugzilla::ModPerl::ResponseHandler';
my $feature_files = Bugzilla::Install::Requirements::map_files_to_features();
@@ -97,16 +100,16 @@ my $feature_files = Bugzilla::Install::Requirements::map_files_to_features();
# This is important to prevent the current directory from getting into
# @INC and messing things up. (See bug 630750.)
no warnings 'redefine';
-local *lib::import = sub {};
+local *lib::import = sub { };
use warnings;
foreach my $file (glob "$cgi_path/*.cgi") {
- my $base_filename = File::Basename::basename($file);
- if (my $feature = $feature_files->{$base_filename}) {
- next if !Bugzilla->feature($feature);
- }
- Bugzilla::Util::trick_taint($file);
- $rl->handler($file, $file);
+ my $base_filename = File::Basename::basename($file);
+ if (my $feature = $feature_files->{$base_filename}) {
+ next if !Bugzilla->feature($feature);
+ }
+ Bugzilla::Util::trick_taint($file);
+ $rl->handler($file, $file);
}
package Bugzilla::ModPerl::ResponseHandler;
@@ -120,29 +123,28 @@ use Bugzilla;
use Bugzilla::Constants qw(USAGE_MODE_REST);
sub handler : method {
- my $class = shift;
-
- # $0 is broken under mod_perl before 2.0.2, so we have to set it
- # here explicitly or init_page's shutdownhtml code won't work right.
- $0 = $ENV{'SCRIPT_FILENAME'};
-
- # Prevent "use lib" from modifying @INC in the case where a .cgi file
- # is being automatically recompiled by mod_perl when Apache is
- # running. (This happens if a file changes while Apache is already
- # running.)
- no warnings 'redefine';
- local *lib::import = sub {};
- use warnings;
-
- Bugzilla::init_page();
- my $result = $class->SUPER::handler(@_);
-
- # When returning data from the REST api we must only return 200 or 304,
- # which tells Apache not to append its error html documents to the
- # response.
- return Bugzilla->usage_mode == USAGE_MODE_REST && $result != 304
- ? Apache2::Const::OK
- : $result;
+ my $class = shift;
+
+ # $0 is broken under mod_perl before 2.0.2, so we have to set it
+ # here explicitly or init_page's shutdownhtml code won't work right.
+ $0 = $ENV{'SCRIPT_FILENAME'};
+
+ # Prevent "use lib" from modifying @INC in the case where a .cgi file
+ # is being automatically recompiled by mod_perl when Apache is
+ # running. (This happens if a file changes while Apache is already
+ # running.)
+ no warnings 'redefine';
+ local *lib::import = sub { };
+ use warnings;
+
+ Bugzilla::init_page();
+ my $result = $class->SUPER::handler(@_);
+
+ # When returning data from the REST api we must only return 200 or 304,
+ # which tells Apache not to append its error html documents to the
+ # response.
+ return Bugzilla->usage_mode == USAGE_MODE_REST
+ && $result != 304 ? Apache2::Const::OK : $result;
}
@@ -155,16 +157,17 @@ use warnings;
use Apache2::Const -compile => qw(OK);
sub handler {
- my $r = shift;
+ my $r = shift;
+
+ Bugzilla::_cleanup();
- Bugzilla::_cleanup();
- # Sometimes mod_perl doesn't properly call DESTROY on all
- # the objects in pnotes()
- foreach my $key (keys %{$r->pnotes}) {
- delete $r->pnotes->{$key};
- }
+ # Sometimes mod_perl doesn't properly call DESTROY on all
+ # the objects in pnotes()
+ foreach my $key (keys %{$r->pnotes}) {
+ delete $r->pnotes->{$key};
+ }
- return Apache2::Const::OK;
+ return Apache2::Const::OK;
}
1;