X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fexception%2FMWException.php;h=c0186f9f76aeb833bc096990fc0b91dd04c55bba;hb=e514fad81b102d15393faf5580f9de255a906d5d;hp=6fd6fb5f25293626312a9a415e69f7b2753f95ab;hpb=44aec8a00a9f0f92a746ca575b58147fea1135e5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/exception/MWException.php b/includes/exception/MWException.php index 6fd6fb5f25..c0186f9f76 100644 --- a/includes/exception/MWException.php +++ b/includes/exception/MWException.php @@ -117,10 +117,12 @@ class MWException extends Exception { $args = array_slice( func_get_args(), 2 ); if ( $this->useMessageCache() ) { - return wfMessage( $key, $args )->text(); - } else { - return wfMsgReplaceArgs( $fallback, $args ); + try { + return wfMessage( $key, $args )->text(); + } catch ( Exception $e ) { + } } + return wfMsgReplaceArgs( $fallback, $args ); } /** @@ -139,10 +141,17 @@ class MWException extends Exception { nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $this ) ) ) . "

\n"; } else { + $logId = MWExceptionHandler::getLogId( $this ); + $type = get_class( $this ); return "
" . - '[' . MWExceptionHandler::getLogId( $this ) . '] ' . - gmdate( 'Y-m-d H:i:s' ) . - ": Fatal exception of type " . get_class( $this ) . "
\n" . + '[' . $logId . '] ' . + gmdate( 'Y-m-d H:i:s' ) . ": " . + $this->msg( "internalerror-fatal-exception", + "Fatal exception of type $1", + $type, + $logId, + MWExceptionHandler::getURL( $this ) + ) . "\n" . ""; @@ -229,8 +238,7 @@ class MWException extends Exception { } elseif ( self::isCommandLine() ) { MWExceptionHandler::printError( $this->getText() ); } else { - self::header( 'HTTP/1.1 500 MediaWiki exception' ); - self::header( 'Status: 500 MediaWiki exception' ); + self::statusHeader( 500 ); self::header( "Content-Type: $wgMimeType; charset=utf-8" ); $this->reportHTML(); @@ -257,4 +265,9 @@ class MWException extends Exception { header( $header ); } } + private static function statusHeader( $code ) { + if ( !headers_sent() ) { + HttpStatus::header( $code ); + } + } }