From 97b5aa9a11b08e6171c7f5f78765a8198e1abe0d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 30 Sep 2016 16:57:38 -0700 Subject: [PATCH] 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 --- includes/exception/MWExceptionHandler.php | 5 ++--- includes/exception/MWExceptionRenderer.php | 15 +++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) 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"; -- 2.20.1