X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fexception%2FMWExceptionRenderer.php;h=a569bcd808ac5d159e0f9024fb5db03926eb740a;hb=55043101b2a89ea1e811b6d35e415f57ed0bf41d;hp=8fdc417c1ef3724b59ab28493af7bfa029669748;hpb=afb713a1fa51bb194d4ffac2d495796c0030fc14;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/exception/MWExceptionRenderer.php b/includes/exception/MWExceptionRenderer.php index 8fdc417c1e..a569bcd808 100644 --- a/includes/exception/MWExceptionRenderer.php +++ b/includes/exception/MWExceptionRenderer.php @@ -60,9 +60,10 @@ class MWExceptionRenderer { MWExceptionHandler::getLogMessage( $eNew ) . "\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."; + $message .= 'Original exception: ' . + MWExceptionHandler::getPublicLogMessage( $e ); + $message .= "\n\nException caught inside exception handler.\n\n" . + self::getShowBacktraceError( $e ); } $message .= "\n"; } else { @@ -74,11 +75,7 @@ class MWExceptionRenderer { $message = MWExceptionHandler::getPublicLogMessage( $e ); } } - if ( self::isCommandLine() ) { - self::printError( $message ); - } else { - echo nl2br( htmlspecialchars( $message ) ) . "\n"; - } + echo nl2br( htmlspecialchars( $message ) ) . "\n"; } } @@ -210,14 +207,14 @@ class MWExceptionRenderer { */ public static function getHTML( $e ) { if ( self::showBackTrace( $e ) ) { - $html = "

" . + $html = "

" . nl2br( htmlspecialchars( MWExceptionHandler::getLogMessage( $e ) ) ) . '

Backtrace:

' . nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $e ) ) ) . "

\n"; } else { $logId = WebRequest::getRequestId(); - $html = "
" . + $html = "
" . '[' . $logId . '] ' . gmdate( 'Y-m-d H:i:s' ) . ": " . self::msg( "internalerror-fatal-exception", @@ -226,9 +223,7 @@ class MWExceptionRenderer { $logId, MWExceptionHandler::getURL() ) . "
\n" . - ""; + ""; } return $html; @@ -262,8 +257,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 +274,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 */