X-Git-Url: http://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fexception%2FMWExceptionRenderer.php;h=5d75036566f616c5ccf3bbfb18f1ac23f8b86558;hp=60d760f3aa2bba4df3cc107009bd9ee6c422e3f6;hb=0e339243f1dbbba5f87a54b116c23e0daec8e2e4;hpb=64b83bdb3afd0ee4f8fc1893a865409c198e601e diff --git a/includes/exception/MWExceptionRenderer.php b/includes/exception/MWExceptionRenderer.php index 60d760f3aa..5d75036566 100644 --- a/includes/exception/MWExceptionRenderer.php +++ b/includes/exception/MWExceptionRenderer.php @@ -33,7 +33,7 @@ class MWExceptionRenderer { /** * @param Exception|Throwable $e Original exception - * @param integer $mode MWExceptionExposer::AS_* constant + * @param int $mode MWExceptionExposer::AS_* constant * @param Exception|Throwable|null $eNew New exception from attempting to show the first */ public static function output( $e, $mode, $eNew = null ) { @@ -47,13 +47,15 @@ class MWExceptionRenderer { self::printError( self::getText( $e ) ); } elseif ( $mode === self::AS_PRETTY ) { self::statusHeader( 500 ); + self::header( "Content-Type: $wgMimeType; charset=utf-8" ); if ( $e instanceof DBConnectionError ) { self::reportOutageHTML( $e ); } else { - self::header( "Content-Type: $wgMimeType; charset=utf-8" ); self::reportHTML( $e ); } } else { + self::statusHeader( 500 ); + self::header( "Content-Type: $wgMimeType; charset=utf-8" ); if ( $eNew ) { $message = "MediaWiki internal error.\n\n"; if ( self::showBackTrace( $e ) ) { @@ -90,7 +92,7 @@ class MWExceptionRenderer { private static function useOutputPage( $e ) { // Can the extension use the Message class/wfMessage to get i18n-ed messages? foreach ( $e->getTrace() as $frame ) { - if ( isset( $frame['class'] ) && $frame['class'] === 'LocalisationCache' ) { + if ( isset( $frame['class'] ) && $frame['class'] === LocalisationCache::class ) { return false; } } @@ -128,7 +130,7 @@ class MWExceptionRenderer { // Show any custom GUI message before the details if ( $e instanceof MessageSpecifier ) { - $wgOut->addHTML( Message::newFromSpecifier( $e )->escaped() ); + $wgOut->addHTML( Html::element( 'p', [], Message::newFromSpecifier( $e )->text() ) ); } $wgOut->addHTML( self::getHTML( $e ) ); @@ -169,14 +171,15 @@ class MWExceptionRenderer { } else { $logId = WebRequest::getRequestId(); $html = "
" . - '[' . $logId . '] ' . - gmdate( 'Y-m-d H:i:s' ) . ": " . - self::msg( "internalerror-fatal-exception", - "Fatal exception of type $1", - get_class( $e ), - $logId, - MWExceptionHandler::getURL() - ) . "
\n" . + htmlspecialchars( + '[' . $logId . '] ' . + gmdate( 'Y-m-d H:i:s' ) . ": " . + self::msg( "internalerror-fatal-exception", + "Fatal exception of type $1", + get_class( $e ), + $logId, + MWExceptionHandler::getURL() + ) ) . "\n" . ""; } @@ -262,7 +265,7 @@ class MWExceptionRenderer { } /** - * @param integer $code + * @param int $code */ private static function statusHeader( $code ) { if ( !headers_sent() ) { @@ -291,7 +294,7 @@ class MWExceptionRenderer { * @param Exception|Throwable $e */ private static function reportOutageHTML( $e ) { - global $wgShowDBErrorBacktrace, $wgShowHostnames, $wgShowSQLErrors; + global $wgShowDBErrorBacktrace, $wgShowHostnames, $wgShowSQLErrors, $wgSitename; $sorry = htmlspecialchars( self::msg( 'dberr-problems', @@ -316,55 +319,20 @@ class MWExceptionRenderer { } MessageCache::singleton()->disable(); // no DB access - - $html = "

$sorry

$again

$info

"; + $html = "\n" . + '' . + '' . + htmlspecialchars( $wgSitename ) . + '' . + '' . + "

$sorry

$again

$info

"; if ( $wgShowDBErrorBacktrace ) { $html .= '

Backtrace:

' .
 				htmlspecialchars( $e->getTraceAsString() ) . '
'; } - $html .= '
'; - $html .= self::googleSearchForm(); - + $html .= ''; echo $html; } - - /** - * @return string - */ - private static function googleSearchForm() { - global $wgSitename, $wgCanonicalServer, $wgRequest; - - $usegoogle = htmlspecialchars( self::msg( - 'dberr-usegoogle', - 'You can try searching via Google in the meantime.' - ) ); - $outofdate = htmlspecialchars( self::msg( - 'dberr-outofdate', - 'Note that their indexes of our content may be out of date.' - ) ); - $googlesearch = htmlspecialchars( self::msg( 'searchbutton', 'Search' ) ); - $search = htmlspecialchars( $wgRequest->getVal( 'search' ) ); - $server = htmlspecialchars( $wgCanonicalServer ); - $sitename = htmlspecialchars( $wgSitename ); - $trygoogle = <<$usegoogle
-$outofdate - -
- - - - - - -

- - -

-
-EOT; - return $trygoogle; - } }