Added/Removed spaces around string concatenation
[lhc/web/wiklou.git] / includes / Exception.php
index 530afd0..93fddac 100644 (file)
@@ -75,11 +75,11 @@ class MWException extends Exception {
                        return null; // Just silently ignore
                }
 
-               if ( !array_key_exists( $name, $wgExceptionHooks ) || !is_array( $wgExceptionHooks[ $name ] ) ) {
+               if ( !array_key_exists( $name, $wgExceptionHooks ) || !is_array( $wgExceptionHooks[$name] ) ) {
                        return null;
                }
 
-               $hooks = $wgExceptionHooks[ $name ];
+               $hooks = $wgExceptionHooks[$name];
                $callargs = array_merge( array( $this ), $args );
 
                foreach ( $hooks as $hook ) {
@@ -130,8 +130,7 @@ class MWException extends Exception {
                                '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .
                                "</p>\n";
                } else {
-                       return
-                               "<div class=\"errorbox\">" .
+                       return "<div class=\"errorbox\">" .
                                '[' . $this->getLogId() . '] ' .
                                gmdate( 'Y-m-d H:i:s' ) .
                                ": Fatal exception of type " . get_class( $this ) . "</div>\n" .
@@ -171,7 +170,7 @@ class MWException extends Exception {
 
        /**
         * Get a random ID for this error.
-        * This allows to link the exception to its correspoding log entry when
+        * This allows to link the exception to its corresponding log entry when
         * $wgShowExceptionDetails is set to false.
         *
         * @return string
@@ -248,7 +247,7 @@ class MWException extends Exception {
         * It will be either HTML or plain text based on isCommandLine().
         */
        function report() {
-               global $wgLogExceptionBacktrace;
+               global $wgLogExceptionBacktrace, $wgMimeType;
                $log = $this->getLogMessage();
 
                if ( $log ) {
@@ -268,6 +267,7 @@ class MWException extends Exception {
                } else {
                        header( "HTTP/1.1 500 MediaWiki exception" );
                        header( "Status: 500 MediaWiki exception", true );
+                       header( "Content-Type: $wgMimeType; charset=utf-8", true );
 
                        $this->reportHTML();
                }
@@ -329,11 +329,17 @@ class ErrorPageError extends MWException {
                $this->msg = $msg;
                $this->params = $params;
 
+               // Bug 44111: Messages in the log files should be in English and not
+               // customized by the local wiki. So get the default English version for
+               // passing to the parent constructor. Our overridden report() below
+               // makes sure that the page shown to the user is not forced to English.
                if( $msg instanceof Message ) {
-                       parent::__construct( $msg );
+                       $enMsg = clone( $msg );
                } else {
-                       parent::__construct( wfMessage( $msg )->text() );
+                       $enMsg = wfMessage( $msg, $params );
                }
+               $enMsg->inLanguage( 'en' )->useDatabase( false );
+               parent::__construct( $enMsg->text() );
        }
 
        function report() {
@@ -611,7 +617,7 @@ class HttpError extends MWException {
                        $content = htmlspecialchars( $this->content );
                }
 
-               return "<!DOCTYPE html>\n".
+               return "<!DOCTYPE html>\n" .
                        "<html><head><title>$header</title></head>\n" .
                        "<body><h1>$header</h1><p>$content</p></body></html>\n";
        }
@@ -715,8 +721,10 @@ class MWExceptionHandler {
                // Final cleanup
                if ( $wgFullyInitialised ) {
                        try {
-                               wfLogProfilingData(); // uses $wgRequest, hence the $wgFullyInitialised condition
-                       } catch ( Exception $e ) {}
+                               // uses $wgRequest, hence the $wgFullyInitialised condition
+                               wfLogProfilingData();
+                       } catch ( Exception $e ) {
+                       }
                }
 
                // Exit value should be nonzero for the benefit of shell jobs