X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fexception%2FMWException.php;h=bebd91580f59aad788b5795bd9ebecc49b08a5ee;hb=94117ad9c15fc57cd5a63204e43f6b190011b135;hp=e54e56852ea3003990f54131ea4c82291c0d9899;hpb=0e54c034458b92199524ea4a8e5e4b7db381ef5d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/exception/MWException.php b/includes/exception/MWException.php index e54e56852e..bebd91580f 100644 --- a/includes/exception/MWException.php +++ b/includes/exception/MWException.php @@ -70,7 +70,7 @@ class MWException extends Exception { * @param array $args Arguments to pass to the callback functions * @return string|null String to output or null if any hook has been called */ - public function runHooks( $name, $args = array() ) { + public function runHooks( $name, $args = [] ) { global $wgExceptionHooks; if ( !isset( $wgExceptionHooks ) || !is_array( $wgExceptionHooks ) ) { @@ -84,7 +84,7 @@ class MWException extends Exception { } $hooks = $wgExceptionHooks[$name]; - $callargs = array_merge( array( $this ), $args ); + $callargs = array_merge( [ $this ], $args ); foreach ( $hooks as $hook ) { if ( @@ -141,7 +141,7 @@ class MWException extends Exception { nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $this ) ) ) . "

\n"; } else { - $logId = MWExceptionHandler::getLogId( $this ); + $logId = WebRequest::getRequestId(); $type = get_class( $this ); return "
" . '[' . $logId . '] ' . @@ -238,8 +238,7 @@ class MWException extends Exception { } elseif ( self::isCommandLine() ) { MWExceptionHandler::printError( $this->getText() ); } else { - self::header( 'HTTP/1.1 500 Internal Server Error' ); - self::header( 'Status: 500 Internal Server Error' ); + self::statusHeader( 500 ); self::header( "Content-Type: $wgMimeType; charset=utf-8" ); $this->reportHTML(); @@ -266,4 +265,9 @@ class MWException extends Exception { header( $header ); } } + private static function statusHeader( $code ) { + if ( !headers_sent() ) { + HttpStatus::header( $code ); + } + } }