From 114dea20cb94964105c4a04365435152171ebe60 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Mon, 16 Feb 2009 04:33:22 +0000 Subject: [PATCH] (bug 17506) Respect $wgShowExceptionDetails when handling exceptions within exceptions. Based on patch by David Tabachnikov and Romi Romano5. --- RELEASE-NOTES | 1 + includes/Exception.php | 52 ++++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a62c463f92..eac9d97742 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -177,6 +177,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Special:PrefixIndex: Move table styling to shared.css, add CSS IDs to tables use correct message 'allpagesprefix' for input form label, replace _ with ' ' in next page link +* (bug 17506) Exceptions within exceptions now respect $wgShowExceptionDetails == API changes in 1.15 == * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions diff --git a/includes/Exception.php b/includes/Exception.php index b71a07b87a..2ccdcc9e1a 100644 --- a/includes/Exception.php +++ b/includes/Exception.php @@ -272,31 +272,33 @@ function wfInstallExceptionHandler() { */ function wfReportException( Exception $e ) { $cmdLine = MWException::isCommandLine(); - if ( $e instanceof MWException ) { - try { - $e->report(); - } catch ( Exception $e2 ) { - // Exception occurred from within exception handler - // Show a simpler error message for the original exception, - // don't try to invoke report() - $message = "MediaWiki internal error.\n\n" . - "Original exception: " . $e->__toString() . - "\n\nException caught inside exception handler: " . - $e2->__toString() . "\n"; - - if ( $cmdLine ) { - wfPrintError( $message ); - } else { - echo nl2br( htmlspecialchars( $message ) ). "\n"; - } - } - } else { - $message = "Unexpected non-MediaWiki exception encountered, of type \"" . get_class( $e ) . "\"\n" . - $e->__toString() . "\n"; - if ( $GLOBALS['wgShowExceptionDetails'] ) { - $message .= "\n" . $e->getTraceAsString() ."\n"; - } - if ( $cmdLine ) { + if ( $e instanceof MWException ) { + try { + $e->report(); + } catch ( Exception $e2 ) { + // Exception occurred from within exception handler + // Show a simpler error message for the original exception, + // don't try to invoke report() + $message = "MediaWiki internal error.\n\n"; + if ( $GLOBALS['wgShowExceptionDetails'] ) + $message .= "Original exception: " . $e->__toString(); + $message .= "\n\nException caught inside exception handler"; + if ( $GLOBALS['wgShowExceptionDetails'] ) + $message .= ": " . $e2->__toString(); + $message .= "\n"; + if ( $cmdLine ) { + wfPrintError( $message ); + } else { + echo nl2br( htmlspecialchars( $message ) ). "\n"; + } + } + } else { + $message = "Unexpected non-MediaWiki exception encountered, of type \"" . get_class( $e ) . "\"\n" . + $e->__toString() . "\n"; + if ( $GLOBALS['wgShowExceptionDetails'] ) { + $message .= "\n" . $e->getTraceAsString() ."\n"; + } + if ( $cmdLine ) { wfPrintError( $message ); } else { echo nl2br( htmlspecialchars( $message ) ). "\n"; -- 2.20.1