From 57a1e7b2705798b9ee8c01339839d5c7895542fa Mon Sep 17 00:00:00 2001 From: Reedy Date: Mon, 21 Nov 2016 21:32:30 +0000 Subject: [PATCH] Replace wgShowExceptionDetails with wgShowDBErrorBacktrace on db errors Bug: T148957 Change-Id: I8891369156547e8931463a2fd55995cfa9e98ee7 --- includes/exception/MWExceptionRenderer.php | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/includes/exception/MWExceptionRenderer.php b/includes/exception/MWExceptionRenderer.php index 8fdc417c1e..873e8f423f 100644 --- a/includes/exception/MWExceptionRenderer.php +++ b/includes/exception/MWExceptionRenderer.php @@ -61,8 +61,7 @@ class MWExceptionRenderer { "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString( $eNew ); } else { $message .= "Exception caught inside exception handler.\n\n" . - "Set \$wgShowExceptionDetails = true; at the bottom of LocalSettings.php " . - "to show detailed debugging information."; + self::getShowBacktraceError( $e ); } $message .= "\n"; } else { @@ -226,9 +225,7 @@ class MWExceptionRenderer { $logId, MWExceptionHandler::getURL() ) . "\n" . - ""; + ""; } return $html; @@ -262,8 +259,7 @@ class MWExceptionRenderer { "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString( $e ) . "\n"; } else { - return "Set \$wgShowExceptionDetails = true; " . - "in LocalSettings.php to show detailed debugging information.\n"; + return self::getShowBacktraceError( $e ); } } @@ -280,6 +276,23 @@ class MWExceptionRenderer { ); } + /** + * @param Exception|Throwable $e + * @return string + */ + private static function getShowBacktraceError( $e ) { + global $wgShowExceptionDetails, $wgShowDBErrorBacktrace; + $vars = []; + if ( !$wgShowExceptionDetails ) { + $vars[] = '$wgShowExceptionDetails = true;'; + } + if ( $e instanceof DBError && !$wgShowDBErrorBacktrace ) { + $vars[] = '$wgShowDBErrorBacktrace = true;'; + } + $vars = implode( ' and ', $vars ); + return "Set $vars at the bottom of LocalSettings.php to show detailed debugging information"; + } + /** * @return bool */ -- 2.20.1