X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fexception%2FMWException.php;h=c0186f9f76aeb833bc096990fc0b91dd04c55bba;hb=8a1152b91365fe51f2505c8dc30dc20319dcafd4;hp=074128f8892cf05db0f56739c21ef4d35edddb83;hpb=92e31275a4f7117a4465b8886dfeca6dcb37351e;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/exception/MWException.php b/includes/exception/MWException.php
index 074128f889..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" .
"";
@@ -222,8 +231,6 @@ class MWException extends Exception {
public function report() {
global $wgMimeType;
- MWExceptionHandler::logException( $this );
-
if ( defined( 'MW_API' ) ) {
// Unhandled API exception, we can't be sure that format printer is alive
self::header( 'MediaWiki-API-Error: internal_api_error_' . get_class( $this ) );
@@ -231,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();
@@ -259,4 +265,9 @@ class MWException extends Exception {
header( $header );
}
}
+ private static function statusHeader( $code ) {
+ if ( !headers_sent() ) {
+ HttpStatus::header( $code );
+ }
+ }
}