]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 407420: CGI::Carp fatalsToBrowser should happen as early as possible
authormkanat%bugzilla.org <>
Sun, 6 Jan 2008 08:53:44 +0000 (08:53 +0000)
committermkanat%bugzilla.org <>
Sun, 6 Jan 2008 08:53:44 +0000 (08:53 +0000)
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=justdave, a=mkanat

Bugzilla.pm
Bugzilla/CGI.pm
mod_perl.pl

index 0750314829210512e818886f50788c5272cc7f5d..c77c039ceb3b994d22af6a68aea9235b464bf090 100644 (file)
@@ -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;
index 3498b3c703ee725359128e8bbcb8652523969997..81141e1cb40b0128a15a0b0b2ce21133e26525f7 100644 (file)
@@ -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} = [];
 
index b4a8f297eaec06cba050f041589d96e87f904b3c..fccc25fb2498546c57006d714923ac357253481e 100644 (file)
@@ -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(@_);
 }