From 22d395ee10f81ecc43ca07e2d0654c158723d05b Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Sun, 6 Jan 2008 08:53:44 +0000 Subject: Bug 407420: CGI::Carp fatalsToBrowser should happen as early as possible Patch By Max Kanat-Alexander r=justdave, a=mkanat --- Bugzilla.pm | 9 +++++++++ Bugzilla/CGI.pm | 7 ------- mod_perl.pl | 5 +++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Bugzilla.pm b/Bugzilla.pm index 075031482..c77c039ce 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -26,6 +26,15 @@ package Bugzilla; use strict; +# We want any compile errors to get to the browser, if possible. +BEGIN { + # This makes sure we're in a CGI. + if ($ENV{SERVER_SOFTWARE} && !$ENV{MOD_PERL}) { + require CGI::Carp; + CGI::Carp->import('fatalsToBrowser'); + } +} + use Bugzilla::Config; use Bugzilla::Constants; use Bugzilla::Auth; diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index 3498b3c70..81141e1cb 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -62,13 +62,6 @@ sub new { my $self = $class->SUPER::new(@args); - if (Bugzilla->error_mode eq ERROR_MODE_WEBPAGE) { - # This happens here so that command-line scripts don't spit out - # their errors in HTML format. - require CGI::Carp; - import CGI::Carp qw(fatalsToBrowser); - } - # Make sure our outgoing cookie list is empty on each invocation $self->{Bugzilla_cookie_list} = []; diff --git a/mod_perl.pl b/mod_perl.pl index b4a8f297e..fccc25fb2 100644 --- a/mod_perl.pl +++ b/mod_perl.pl @@ -92,6 +92,11 @@ sub handler : method { # $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'}; + + # Make all errors go to the browser, not the log. + require CGI::Carp; + CGI::Carp->import('fatalsToBrowser'); + Bugzilla::init_page(); return $class->SUPER::handler(@_); } -- cgit v1.2.3-24-g4f1b