r47305 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47304‎ | r47305 | r47306 >
Date:04:33, 16 February 2009
Author:demon
Status:resolved (Comments)
Tags:
Comment:
(bug 17506) Respect $wgShowExceptionDetails when handling exceptions within exceptions. Based on patch by David Tabachnikov and Romi Romano5.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Exception.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Exception.php
@@ -272,31 +272,33 @@
273273 */
274274 function wfReportException( Exception $e ) {
275275 $cmdLine = MWException::isCommandLine();
276 - if ( $e instanceof MWException ) {
277 - try {
278 - $e->report();
279 - } catch ( Exception $e2 ) {
280 - // Exception occurred from within exception handler
281 - // Show a simpler error message for the original exception,
282 - // don't try to invoke report()
283 - $message = "MediaWiki internal error.\n\n" .
284 - "Original exception: " . $e->__toString() .
285 - "\n\nException caught inside exception handler: " .
286 - $e2->__toString() . "\n";
287 -
288 - if ( $cmdLine ) {
289 - wfPrintError( $message );
290 - } else {
291 - echo nl2br( htmlspecialchars( $message ) ). "\n";
292 - }
293 - }
294 - } else {
295 - $message = "Unexpected non-MediaWiki exception encountered, of type \"" . get_class( $e ) . "\"\n" .
296 - $e->__toString() . "\n";
297 - if ( $GLOBALS['wgShowExceptionDetails'] ) {
298 - $message .= "\n" . $e->getTraceAsString() ."\n";
299 - }
300 - if ( $cmdLine ) {
 276+ if ( $e instanceof MWException ) {
 277+ try {
 278+ $e->report();
 279+ } catch ( Exception $e2 ) {
 280+ // Exception occurred from within exception handler
 281+ // Show a simpler error message for the original exception,
 282+ // don't try to invoke report()
 283+ $message = "MediaWiki internal error.\n\n";
 284+ if ( $GLOBALS['wgShowExceptionDetails'] )
 285+ $message .= "Original exception: " . $e->__toString();
 286+ $message .= "\n\nException caught inside exception handler";
 287+ if ( $GLOBALS['wgShowExceptionDetails'] )
 288+ $message .= ": " . $e2->__toString();
 289+ $message .= "\n";
 290+ if ( $cmdLine ) {
 291+ wfPrintError( $message );
 292+ } else {
 293+ echo nl2br( htmlspecialchars( $message ) ). "\n";
 294+ }
 295+ }
 296+ } else {
 297+ $message = "Unexpected non-MediaWiki exception encountered, of type \"" . get_class( $e ) . "\"\n" .
 298+ $e->__toString() . "\n";
 299+ if ( $GLOBALS['wgShowExceptionDetails'] ) {
 300+ $message .= "\n" . $e->getTraceAsString() ."\n";
 301+ }
 302+ if ( $cmdLine ) {
301303 wfPrintError( $message );
302304 } else {
303305 echo nl2br( htmlspecialchars( $message ) ). "\n";
Index: trunk/phase3/RELEASE-NOTES
@@ -177,6 +177,7 @@
178178 * Special:PrefixIndex: Move table styling to shared.css, add CSS IDs to tables
179179 use correct message 'allpagesprefix' for input form label, replace _ with ' '
180180 in next page link
 181+* (bug 17506) Exceptions within exceptions now respect $wgShowExceptionDetails
181182
182183 == API changes in 1.15 ==
183184 * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions

Comments

#Comment by Brion VIBBER (talk | contribs)   21:05, 17 February 2009

The change is obscured by some whitespace funkiness here... Cleanup?

#Comment by 😂 (talk | contribs)   21:36, 17 February 2009

Cleanup in r47379

Status & tagging log