(bug 17506) Respect $wgShowExceptionDetails when handling exceptions within exception...
authorChad Horohoe <demon@users.mediawiki.org>
Mon, 16 Feb 2009 04:33:22 +0000 (04:33 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Mon, 16 Feb 2009 04:33:22 +0000 (04:33 +0000)
RELEASE-NOTES
includes/Exception.php

index a62c463..eac9d97 100644 (file)
@@ -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
index b71a07b..2ccdcc9 100644 (file)
@@ -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";