]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 510958: Allow hooks to exit() under mod_perl
authormkanat%bugzilla.org <>
Wed, 16 Sep 2009 00:16:20 +0000 (00:16 +0000)
committermkanat%bugzilla.org <>
Wed, 16 Sep 2009 00:16:20 +0000 (00:16 +0000)
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=dkl, a=mkanat

Bugzilla/Hook.pm

index 990c6f1170e544d9da6984f9f1c3422530920cb6..2eda8d856df14b4a692cefdf7ab086d616e061ad 100644 (file)
 #
 
 package Bugzilla::Hook;
+use strict;
 
 use Bugzilla::Constants;
 use Bugzilla::Util;
 use Bugzilla::Error;
 
-use strict;
+use Scalar::Util qw(blessed);
+
+BEGIN {
+    if ($ENV{MOD_PERL}) {
+        require ModPerl::Const;
+        import ModPerl::Const -compile => 'EXIT';
+     }
+    else {
+        # Create a fake constant. We have to do this in a string eval,
+        # otherwise this will always be defined.
+        eval('sub ModPerl::EXIT;');
+    }
+}
 
 sub process {
     my ($name, $args) = @_;
@@ -49,8 +62,16 @@ sub process {
             # Allow extensions to load their own libraries.
             local @INC = ("$extension/lib", @INC);
             do($extension.'/code/'.$name.'.pl');
-            ThrowCodeError('extension_invalid', 
-                { errstr => $@, name => $name, extension => $extension }) if $@;
+            if ($@) {
+                if ($ENV{MOD_PERL} and blessed $@ and $@ == ModPerl::EXIT) {
+                    exit;
+                }
+                else {
+                    ThrowCodeError('extension_invalid', 
+                        { errstr => $@, name => $name,
+                          extension => $extension });
+                }
+            }
             # Flush stored data.
             Bugzilla->hook_args({});
         }