Merge "Fix exception in Import, when import of a revision fails"
[lhc/web/wiklou.git] / includes / exception / MWException.php
index 097c043..c0186f9 100644 (file)
@@ -119,7 +119,8 @@ class MWException extends Exception {
                if ( $this->useMessageCache() ) {
                        try {
                                return wfMessage( $key, $args )->text();
-                       } catch ( Exception $e ) {}
+                       } catch ( Exception $e ) {
+                       }
                }
                return wfMsgReplaceArgs( $fallback, $args );
        }
@@ -237,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();
@@ -265,4 +265,9 @@ class MWException extends Exception {
                        header( $header );
                }
        }
+       private static function statusHeader( $code ) {
+               if ( !headers_sent() ) {
+                       HttpStatus::header( $code );
+               }
+       }
 }