Allow hooks to exit() under mod_perl

RESOLVED FIXED in Bugzilla 3.6

Status

()

--
enhancement
RESOLVED FIXED
10 years ago
9 years ago

People

(Reporter: mkanat, Assigned: mkanat)

Tracking

Bugzilla 3.6
Bug Flags:
approval +

Details

(Whiteboard: [es-gnome])

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

10 years ago
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_
(Assignee)

Comment 1

10 years ago
Created attachment 394886 [details] [diff] [review]
v1

Okay, I've tested this with my own extension and it works.
Assignee: general → mkanat
Status: NEW → ASSIGNED
Attachment #394886 - Flags: review?(dkl)
(Assignee)

Updated

10 years ago
Whiteboard: [es-gnome]
(Assignee)

Comment 2

10 years ago
Created attachment 394892 [details] [diff] [review]
v2

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
(Assignee)

Comment 4

9 years ago
(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+
(Assignee)

Updated

9 years ago
Flags: approval+

Comment 6

9 years ago
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.
(Assignee)

Comment 7

9 years ago
(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.
(Assignee)

Comment 8

9 years ago
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
Last Resolved: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.