From 9e8fbe7f9b773a7b73688c79ea24bb0d402560f6 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" Date: Wed, 16 Sep 2009 00:16:20 +0000 Subject: [PATCH] Bug 510958: Allow hooks to exit() under mod_perl Patch by Max Kanat-Alexander r=dkl, a=mkanat git-svn-id: svn://10.0.0.236/trunk@258397 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/Bugzilla/Hook.pm | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/mozilla/webtools/bugzilla/Bugzilla/Hook.pm b/mozilla/webtools/bugzilla/Bugzilla/Hook.pm index 990c6f1170e..2eda8d856df 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Hook.pm +++ b/mozilla/webtools/bugzilla/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({}); }