From: Reedy Date: Mon, 21 Nov 2016 21:32:30 +0000 (+0000) Subject: Replace wgShowExceptionDetails with wgShowDBErrorBacktrace on db errors X-Git-Tag: 1.31.0-rc.0~4802^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/%24wgLogo?a=commitdiff_plain;h=57a1e7b2705798b9ee8c01339839d5c7895542fa;p=lhc%2Fweb%2Fwiklou.git Replace wgShowExceptionDetails with wgShowDBErrorBacktrace on db errors Bug: T148957 Change-Id: I8891369156547e8931463a2fd55995cfa9e98ee7 --- 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 */