Closed Bug 300978 Opened 19 years ago Closed 18 years ago

bad output when a non-cgi script dies

Categories

(Bugzilla :: Bugzilla-General, defect, P1)

2.21
defect

Tracking

()

RESOLVED FIXED
Bugzilla 2.22

People

(Reporter: LpSolit, Assigned: mkanat)

References

Details

(Keywords: regression)

Attachments

(1 file, 1 obsolete file)

It's a regression due to bug 283989. CGI.pm, line 39, contains:

use CGI::Carp qw(fatalsToBrowser);


This makes non-cgi scripts to display HTML content when dying:

[root@antares bugzilla]# ./collectstats.pl
Content-type: text/html

<h1>Software error:</h1>
<pre>pomme at ./collectstats.pl line 57.</pre>
<p>
For help, please send mail to this site's webmaster, giving this error message
and the time and date of the error.

</p>


collectstats.pl "use Bugzilla;", which "use Bugzilla::CGI;".

Removing this line completely looks like the best solution to me.
Keywords: regression
Target Milestone: --- → Bugzilla 2.22
Ahhh. Hrm... I think the solution is to only do a "require Bugzilla::CGI" when
it's actually needed in Bugzilla.pm, which might be almost never...
Attached patch Patch (obsolete) — Splinter Review
This seems to work. Note removing the dependency on CGI::Carp from
Bugzilla::Bug.pm.

I feel a little uncomfortable about this because the global init code is being
called later now than before. Perhaps the global init code should rather be
moved to Bugzilla.pm?
Assignee: general → wurblzap
Status: NEW → ASSIGNED
Attachment #189513 - Flags: review?(LpSolit)
Well, the global init code really does look like it belongs in CGI.pm. I think
we're probably okay. Another thing we could do to fix this (at least, something
we could try) would be to require CGI::Carp and import fatalsToBrowser only if
i_am_cgi().

We'd have to check the CGI::Carp docs to make sure that that would be okay...
Oh, but one way or another, whatever solution we decide on will need a comment,
so other developers years from now aren't confused about why we're doing
"require" statements in strange places. :-)
Comment on attachment 189513 [details] [diff] [review]
Patch

run ./collectstats.pl and ./whine.pl with this patch applied. Enjoy!

[root@antares bugzilla]# ./collectstats.pl
Can't locate object method "new" via package "Bugzilla::CGI" at
./collectstats.pl line 489.
[root@antares bugzilla]# ./whine.pl
Can't locate object method "new" via package "Bugzilla::CGI" at ./whine.pl line
461.

Adding use Bugzilla::CGI; at the top of these two files fix the problem, but
the output again displays HTML. :(

Non-cgi scripts should not create CGI objects IMO.
Attachment #189513 - Flags: review?(LpSolit) → review-
(In reply to comment #5)
> Non-cgi scripts should not create CGI objects IMO.

Note that the culprit is Search.pm which requires a CGI object in order to run
saved queries.
(In reply to comment #6)
> Note that the culprit is Search.pm which requires a CGI object in order to run
> saved queries.

In this case, I don't think I'll manage to patch this bug any time soon :(
Assignee: wurblzap → general
Status: ASSIGNED → NEW
I think we'll need to do an "eval use" if i_am_cgi perhaps, on the CGI::Carp
qw(fatalsToBrowser) thing.
Assignee: general → mkanat
*** Bug 313421 has been marked as a duplicate of this bug. ***
Let's have bug 319140 block this one. We can have an i_am_cgi check added easily after a patch along the lines of the current one on bug 319140 has landed.
Depends on: 319140
Priority: -- → P1
Attached patch v2Splinter Review
Finally, a patch for this bug. :-) I've always suspected this would fix it, I just didn't remember or have the time to do it before now. :-)
Attachment #189513 - Attachment is obsolete: true
Attachment #230649 - Flags: review?(LpSolit)
Comment on attachment 230649 [details] [diff] [review]
v2

Great fix! :) Tested on both tip and 2.22. r=LpSolit
Attachment #230649 - Flags: review?(LpSolit) → review+
Status: NEW → ASSIGNED
Flags: approval?
Flags: approval2.22?
No longer depends on: 319140
Flags: approval?
Flags: approval2.22?
Flags: approval2.22+
Flags: approval+
tip:

Checking in Bugzilla/Bug.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Bug.pm,v  <--  Bug.pm
new revision: 1.130; previous revision: 1.129
done
Checking in Bugzilla/CGI.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/CGI.pm,v  <--  CGI.pm
new revision: 1.27; previous revision: 1.26
done

2.22:

Checking in Bugzilla/Bug.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Bug.pm,v  <--  Bug.pm
new revision: 1.104.2.4; previous revision: 1.104.2.3
done
Checking in Bugzilla/CGI.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/CGI.pm,v  <--  CGI.pm
new revision: 1.20.2.3; previous revision: 1.20.2.2
done
Status: ASSIGNED → RESOLVED
Closed: 18 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: