summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2009-09-16 02:16:20 +0200
committermkanat%bugzilla.org <>2009-09-16 02:16:20 +0200
commit540d08b4b84c5d4bb4df362d9bed12da3ac02d24 (patch)
tree2e3dc5f7538018aadff4facee0b61cb062086fd4
parent2d952ffa8c9f22b1c2c7930bc4e2673e72e51f5b (diff)
downloadbugzilla-540d08b4b84c5d4bb4df362d9bed12da3ac02d24.tar.gz
bugzilla-540d08b4b84c5d4bb4df362d9bed12da3ac02d24.tar.xz
Bug 510958: Allow hooks to exit() under mod_perl
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=dkl, a=mkanat
-rw-r--r--Bugzilla/Hook.pm27
1 files changed, 24 insertions, 3 deletions
diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm
index 990c6f117..2eda8d856 100644
--- a/Bugzilla/Hook.pm
+++ b/Bugzilla/Hook.pm
@@ -21,12 +21,25 @@
#
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({});
}