Last modified: 2009-01-06 22:18:12 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T11243, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 9243 - Avoid exit to make MW handle page exceptions properly
Avoid exit to make MW handle page exceptions properly
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.10.x
All All
: Normal trivial (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch
Depends on: 7830
Blocks:
  Show dependency treegraph
 
Reported: 2007-03-09 21:59 UTC by MrPete
Modified: 2009-01-06 22:18 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch implements try/catch duplicating present function (2.18 KB, patch)
2007-03-09 22:01 UTC, MrPete
Details

Description MrPete 2007-03-09 21:59:24 UTC
MediaWiki contains a few calls to "exit" after generating pages that otherwise
would be cleanly generated. Beginning with PHP5, this is no longer necessary as
an error-handling mechanism.

The attached patch replaces all such exit calls with exception 'throw' and adds
a try/catch framework to index.php

This has the beneficial side effect of making MW far more easily customized via
minor adjustments to index.php
Comment 1 MrPete 2007-03-09 22:01:18 UTC
Created attachment 3330 [details]
Patch implements try/catch duplicating present function

It is possible that the "catch" should come earlier in index.php -- is it
really desirable to skip all final page-handling when page-generation hits a
snag?

This patch implements the exception as if we really do want to do the
equivalent of "exit" under default conditions... but that may not be correct.
Comment 2 Aryeh Gregor (not reading bugmail, please e-mail directly) 2007-03-09 22:30:15 UTC
If exceptions are used, they should presumably be MWExceptions and give descriptive error 
messages (although I suppose it doesn't make much difference).
Comment 3 Brion Vibber 2007-03-09 22:51:58 UTC
My impression is that those are places where it really _oughtn't_ to be exiting,
but rather things should be allowed to close out gracefully. So rather than
using exceptions of any kind, I'd rather see them changed to just exit (this may
require fixing code that uses them that makes the assumption they cause exits).
Comment 4 MrPete 2007-03-10 10:20:22 UTC
Brian, I presume you mean "changed to just return". Yes, the whole issue is how
to close out gracefully after giving a "nice" wikitext error message to the
user, an error that has stopped normal page processing in its tracks (e.g. "no
permission".) 

It would be great if someone with more MW code experience is able to discern an
appropriate return-based strategy that doesn't cause hiccups to the entire code
base. Any takers?

In the meantime, I'm happy with exception-throwing as an interim improvement
over the current exit "strategy" :)

If this bugfix is to use MWExceptions, we would a) need a new type of
MWException (producing no report); and b) be assured that catching MWExceptions
at the outer level is not an issue.

As for descriptive error messages, sure, that can be done. Simetrical is correct
that it doesn't make much difference -- the message would be invisible to the
user, and solely for developer understanding. In these cases, the code has
already created informative wikitext error messages for the user; there's
nothing more to be created for the user. 

The sole purpose of this change is to enable proper cleanup. In my case, all of
MW is wrapped inside another package, so "proper cleanup" has rather large
significance :)
Comment 5 Aaron Schulz 2009-01-02 11:38:05 UTC
Done in r45314, except for the index.php stuff
Comment 6 Brion Vibber 2009-01-06 22:18:12 UTC
those bits were changed a bunch in r45320

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links