Add i18n for the infamous "Fatal exception of type MWException" errorbox
authorFederico Leva <federicoleva@tiscali.it>
Thu, 12 Feb 2015 23:01:54 +0000 (00:01 +0100)
committerBryanDavis <bdavis@wikimedia.org>
Mon, 23 Feb 2015 21:33:24 +0000 (21:33 +0000)
These errors usually need to be reported, so it's better for the user
to understand them as much as possible.

Bug: T40095
Change-Id: Ibd2f984b66acb9150400126f21acf7cc5fc85acd

includes/exception/MWException.php
languages/i18n/en.json
languages/i18n/qqq.json

index 6fd6fb5..097c043 100644 (file)
@@ -117,10 +117,11 @@ 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 +140,17 @@ class MWException extends Exception {
                        nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $this ) ) ) .
                        "</p>\n";
                } else {
+                       $logId = MWExceptionHandler::getLogId( $this );
+                       $type = get_class( $this );
                        return "<div class=\"errorbox\">" .
-                       '[' . MWExceptionHandler::getLogId( $this ) . '] ' .
-                       gmdate( 'Y-m-d H:i:s' ) .
-                       ": Fatal exception of type " . get_class( $this ) . "</div>\n" .
+                       '[' . $logId . '] ' .
+                       gmdate( 'Y-m-d H:i:s' ) . ": " .
+                       $this->msg( "internalerror-fatal-exception",
+                               "Fatal exception of type $1",
+                               $type,
+                               $logId,
+                               MWExceptionHandler::getURL( $this )
+                       ) . "</div>\n" .
                        "<!-- Set \$wgShowExceptionDetails = true; " .
                        "at the bottom of LocalSettings.php to show detailed " .
                        "debugging information. -->";
index 96e3e3e..31c766f 100644 (file)
        "readonly_lag": "The database has been automatically locked while the slave database servers catch up to the master",
        "internalerror": "Internal error",
        "internalerror_info": "Internal error: $1",
+       "internalerror-fatal-exception": "Fatal exception of type \"$1\"",
        "filecopyerror": "Could not copy file \"$1\" to \"$2\".",
        "filerenameerror": "Could not rename file \"$1\" to \"$2\".",
        "filedeleteerror": "Could not delete file \"$1\".",
index 9968cc9..021b865 100644 (file)
        "readonly_lag": "Error message displayed when the database is locked.",
        "internalerror": "{{Identical|Internal error}}",
        "internalerror_info": "Parameters:\n* $1 - error message",
+       "internalerror-fatal-exception": "Error message displayed by MediaWiki itself when the request failed, inside an error box which also contains a code, a timestamp and a colon before this message.\nParameters:\n* $1 - proper name of the kind of error\n* $2 - alphanumeric code identifying the error in the server logs\n* $3 - URL which resulted in the error\n$2 and $3 are not used by default and only available for wiki customisations, because they are useful for communication to the wiki system administrator.",
        "filecopyerror": "Parameters:\n* $1 - source file name\n* $2 - destination file name",
        "filerenameerror": "Parameters:\n* $1 - old file name\n* $2 - new file name",
        "filedeleteerror": "Parameters:\n* $1 - file name",