Closed Bug 510958 Opened 15 years ago Closed 15 years ago

Allow hooks to exit() under mod_perl

Categories

(Bugzilla :: Bugzilla-General, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 3.6

People

(Reporter: mkanat, Assigned: mkanat)

Details

(Whiteboard: [es-gnome])

Attachments

(1 file, 1 obsolete file)

Under mod_perl, exit() is implemented as a special form of "die". Unfortunately, when called by a hook, this is caught as though it were an error.

There is a workaround specified in the mod_perl docs, here:

http://perl.apache.org/docs/2.0/api/ModPerl/Util.html#C_exit_
Attached patch v1 (obsolete) — Splinter Review
Okay, I've tested this with my own extension and it works.
Assignee: general → mkanat
Status: NEW → ASSIGNED
Attachment #394886 - Flags: review?(dkl)
Whiteboard: [es-gnome]
Attached patch v2Splinter Review
The previous patch was throwing the following error under mod_perl when loading Apache:

Prototype mismatch: sub ModPerl::EXIT () vs none at /var/www/html/everythingsolved.com/sites/gnome-working/Bugzilla/Hook.pm line 39.
Attachment #394886 - Attachment is obsolete: true
Attachment #394892 - Flags: review?(dkl)
Attachment #394886 - Flags: review?(dkl)
Ok in testing this patch, I may be hitting up against the extend of my ModPerl knowledge and need to pick your brain to see what I am doing wrong. 

When a person puts an exit() call in an extension .pl code file, what should I be seeing to the client? Currently with the patch I get a internal 500 error and the error_log gives me a premature end of script headers error against whatever cgi I am looking at. Is that what I should be seeing? If I just put a code error of some kind in the .pl file, I then get the normal extension_invalid error message.

Can you maybe paste an example of extension code that utilizes exit and maybe I am doing it in an unsupported away.

FWIW, I get the same premature header error when using exit without the patch.

Thanks
Dave
(In reply to comment #3)
> When a person puts an exit() call in an extension .pl code file, what should I
> be seeing to the client?

  You should be seeing nothing. Of course, one would generally expect that CGI headers had been sent first, or Apache might get confused.


> Can you maybe paste an example of extension code that utilizes exit and maybe I
> am doing it in an unsupported away.

  There's an exit() in traceparser here:

  http://bzr.everythingsolved.com/bugzilla-traceparser/trunk/annotate/head%3A/lib/TraceParser/Hooks.pm#L107

> FWIW, I get the same premature header error when using exit without the patch.

  Did you restart httpd after applying the patch? Are the checksetup permissions and the SELinux permissions right?
Comment on attachment 394892 [details] [diff] [review]
v2

Ok, now that I figured out what I was doing wrong prior, I have been able to complete testing for this new function. All works as expected and now when I call exit() from my extension code, it will display the template proper and stop execution without throwing an extension error. r=dkl
Attachment #394892 - Flags: review?(dkl) → review+
Flags: approval+
Comment on attachment 394892 [details] [diff] [review]
v2

>+    else {
>+        # Create a fake constant. We have to do this in a string eval,
>+        # otherwise this will always be defined.
>+        eval('sub ModPerl::EXIT;');
>+    }

Why is that useful? You never call ModPerl::EXIT if you don't use mod_perl. I don't understand what's the point here.
(In reply to comment #6)
> Why is that useful? You never call ModPerl::EXIT if you don't use mod_perl. I
> don't understand what's the point here.

  Because ModPerl::EXIT exists as a bareword in the code.
Checking in Bugzilla/Hook.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Hook.pm,v  <--  Hook.pm
new revision: 1.29; previous revision: 1.28
done
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: