X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fexception%2FMWExceptionRenderer.php;h=c0f1e84404b1b362e8e966bf1bfa24cb4a6de897;hp=8fdc417c1ef3724b59ab28493af7bfa029669748;hb=5433c9357df94b11d79fd1c2f0cf9261dbb84e2a;hpb=12313956c58e88b98d4baf722464e09b4a351bf3 diff --git a/includes/exception/MWExceptionRenderer.php b/includes/exception/MWExceptionRenderer.php index 8fdc417c1e..c0f1e84404 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 { @@ -74,11 +73,7 @@ class MWExceptionRenderer { $message = MWExceptionHandler::getPublicLogMessage( $e ); } } - if ( self::isCommandLine() ) { - self::printError( $message ); - } else { - echo nl2br( htmlspecialchars( $message ) ) . "\n"; - } + echo nl2br( htmlspecialchars( $message ) ) . "\n"; } } @@ -226,9 +221,7 @@ class MWExceptionRenderer { $logId, MWExceptionHandler::getURL() ) . "\n" . - ""; + ""; } return $html; @@ -262,8 +255,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 +272,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 */