From: Aaron Schulz Date: Fri, 30 Sep 2016 23:57:38 +0000 (-0700) Subject: Exception rendering fixes X-Git-Tag: 1.31.0-rc.0~5250^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=97b5aa9a11b08e6171c7f5f78765a8198e1abe0d;p=lhc%2Fweb%2Fwiklou.git Exception rendering fixes * Actually use MWExceptionRenderer::AS_RAW. Use this after an error is thrown while trying to pretty render the original error. This is how this case was originally handled before. * Do not show the google form or file cache in CLI mode. Change-Id: I130499753efbf8b4d6d254ea36bacb2473952c1b --- diff --git a/includes/exception/MWExceptionHandler.php b/includes/exception/MWExceptionHandler.php index 797b3af2f3..4a1f190c75 100644 --- a/includes/exception/MWExceptionHandler.php +++ b/includes/exception/MWExceptionHandler.php @@ -68,14 +68,13 @@ class MWExceptionHandler { // removed. $e->report(); } else { - MWExceptionRenderer::output( - $e, MWExceptionRenderer::AS_PRETTY ); + MWExceptionRenderer::output( $e, MWExceptionRenderer::AS_PRETTY ); } } catch ( Exception $e2 ) { // Exception occurred from within exception handler // Show a simpler message for the original exception, // don't try to invoke report() - MWExceptionRenderer::output( $e, MWExceptionRenderer::AS_PRETTY, $e2 ); + MWExceptionRenderer::output( $e, MWExceptionRenderer::AS_RAW, $e2 ); } } diff --git a/includes/exception/MWExceptionRenderer.php b/includes/exception/MWExceptionRenderer.php index aba131d1ee..8fdc417c1e 100644 --- a/includes/exception/MWExceptionRenderer.php +++ b/includes/exception/MWExceptionRenderer.php @@ -35,11 +35,6 @@ class MWExceptionRenderer { public static function output( $e, $mode, $eNew = null ) { global $wgMimeType; - if ( $e instanceof DBConnectionError ) { - self::reportOutageHTML( $e ); - return; - } - if ( defined( 'MW_API' ) ) { // Unhandled API exception, we can't be sure that format printer is alive self::header( 'MediaWiki-API-Error: internal_api_error_' . get_class( $e ) ); @@ -47,9 +42,13 @@ class MWExceptionRenderer { } elseif ( self::isCommandLine() ) { self::printError( self::getText( $e ) ); } elseif ( $mode === self::AS_PRETTY ) { - self::statusHeader( 500 ); - self::header( "Content-Type: $wgMimeType; charset=utf-8" ); - self::reportHTML( $e ); + if ( $e instanceof DBConnectionError ) { + self::reportOutageHTML( $e ); + } else { + self::statusHeader( 500 ); + self::header( "Content-Type: $wgMimeType; charset=utf-8" ); + self::reportHTML( $e ); + } } else { if ( $eNew ) { $message = "MediaWiki internal error.\n\n";