Fix flush-like commit in DeferredUpdates.
[lhc/web/wiklou.git] / includes / Exception.php
index d5cf543..714f73e 100644 (file)
@@ -45,7 +45,7 @@ class MWException extends Exception {
        }
 
        /**
-        * Can the extension use wfMsg() to get i18n messages?
+        * Can the extension use the Message class/wfMessage to get i18n-ed messages?
         *
         * @return bool
         */
@@ -109,7 +109,7 @@ class MWException extends Exception {
                $args = array_slice( func_get_args(), 2 );
 
                if ( $this->useMessageCache() ) {
-                       return wfMsgNoTrans( $key, $args );
+                       return wfMessage( $key, $args )->plain();
                } else {
                        return wfMsgReplaceArgs( $fallback, $args );
                }
@@ -240,7 +240,6 @@ class MWException extends Exception {
                        }
 
                        echo "</body></html>\n";
-                       die( 1 );
                }
        }
 
@@ -319,13 +318,11 @@ class ErrorPageError extends MWException {
        public $title, $msg, $params;
 
        /**
-        * @todo document
+        * Note: these arguments are keys into wfMessage(), not text!
         *
-        * Note: these arguments are keys into wfMsg(), not text!
-        *
-        * @param $title A title
-        * @param $msg String|Message . In string form, should be a message key
-        * @param $params Array Array to wfMsg()
+        * @param $title string|Message Message key (string) for page title, or a Message object
+        * @param $msg string|Message Message key (string) for error text, or a Message object
+        * @param $params array with parameters to wfMessage()
         */
        function __construct( $title, $msg, $params = null ) {
                $this->title = $title;
@@ -335,7 +332,7 @@ class ErrorPageError extends MWException {
                if( $msg instanceof Message ){
                        parent::__construct( $msg );
                } else {
-                       parent::__construct( wfMsg( $msg ) );
+                       parent::__construct( wfMessage( $msg )->text() );
                }
        }
 
@@ -356,10 +353,9 @@ class ErrorPageError extends MWException {
  * @ingroup Exception
  */
 class BadTitleError extends ErrorPageError {
-
        /**
-        * @param $msg string A message key (default: 'badtitletext')
-        * @param $params Array parameter to wfMsg()
+        * @param $msg string|Message A message key (default: 'badtitletext')
+        * @param $params Array parameter to wfMessage()
         */
        function __construct( $msg = 'badtitletext', $params = null ) {
                parent::__construct( 'badtitle', $msg, $params );
@@ -477,7 +473,7 @@ class UserBlockedError extends ErrorPageError {
 
                $reason = $block->mReason;
                if( $reason == '' ) {
-                       $reason = wfMsg( 'blockednoreason' );
+                       $reason = wfMessage( 'blockednoreason' )->text();
                }
 
                /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
@@ -536,7 +532,7 @@ class UserNotLoggedIn extends ErrorPageError {
         *        Optional, default: 'exception-nologin-text'
         * @param $titleMsg A message key to set the page title.
         *        Optional, default: 'exception-nologin'
-        * @param $params Parameters to wfMsg().
+        * @param $params Parameters to wfMessage().
         *        Optiona, default: null
         */
        public function __construct(
@@ -642,7 +638,7 @@ class MWExceptionHandler {
                                if ( $cmdLine ) {
                                        self::printError( $message );
                                } else {
-                                       self::escapeEchoAndDie( $message );
+                                       echo nl2br( htmlspecialchars( $message ) ) . "\n";
                                }
                        }
                } else {
@@ -656,7 +652,7 @@ class MWExceptionHandler {
                        if ( $cmdLine ) {
                                self::printError( $message );
                        } else {
-                               self::escapeEchoAndDie( $message );
+                               echo nl2br( htmlspecialchars( $message ) ) . "\n";
                        }
                }
        }
@@ -677,17 +673,6 @@ class MWExceptionHandler {
                }
        }
 
-       /**
-        * Print a message after escaping it and converting newlines to <br>
-        * Use this for non-command line failures.
-        *
-        * @param $message string Failure text
-        */
-       private static function escapeEchoAndDie( $message ) {
-               echo nl2br( htmlspecialchars( $message ) ) . "\n";
-               die(1);
-       }
-
        /**
         * Exception handler which simulates the appropriate catch() handling:
         *