Make MessageCache::get() return false if the requested message does not exist, and...
authorHappy-melon <happy-melon@users.mediawiki.org>
Thu, 25 Mar 2010 20:21:31 +0000 (20:21 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Thu, 25 Mar 2010 20:21:31 +0000 (20:21 +0000)
includes/GlobalFunctions.php
includes/MessageCache.php
languages/LanguageConverter.php

index 36860e3..a038fb0 100644 (file)
@@ -750,7 +750,9 @@ function wfMsgGetKey( $key, $useDB, $langCode = false, $transform = true ) {
        # If $wgMessageCache isn't initialised yet, try to return something sensible.
        if( is_object( $wgMessageCache ) ) {
                $message = $wgMessageCache->get( $key, $useDB, $langCode );
-               if ( $transform ) {
+               if( $message === false ){
+                       $message = '&lt;' . htmlspecialchars( $key ) . '&gt;';
+               } elseif ( $transform ) {
                        $message = $wgMessageCache->transform( $message );
                }
        } else {
@@ -2267,12 +2269,12 @@ function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) {
  * looked up didn't exist but a XHTML string, this function checks for the
  * nonexistance of messages by looking at wfMsg() output
  *
- * @param $msg      String: the message key looked up
- * @param $wfMsgOut String: the output of wfMsg*()
- * @return Boolean
+ * @param $key      String: the message key looked up
+ * @return Boolean True if the message *doesn't* exist.
  */
-function wfEmptyMsg( $msg, $wfMsgOut ) {
-       return $wfMsgOut === htmlspecialchars( "<$msg>" );
+function wfEmptyMsg( $key ) {
+       global $wgMessageCache;
+       return $wgMessageCache->get( $key ) === false;
 }
 
 /**
index 2c53430..318d1de 100644 (file)
@@ -500,7 +500,7 @@ class MessageCache {
 
                if ( strval( $key ) === '' ) {
                        # Shortcut: the empty key is always missing
-                       return '&lt;&gt;';
+                       return false;
                }
 
                $lang = wfGetLangObj( $langcode );
@@ -558,7 +558,7 @@ class MessageCache {
 
                # Final fallback
                if( $message === false ) {
-                       return '&lt;' . htmlspecialchars($key) . '&gt;';
+                       return false;
                }
 
                # Fix whitespace
index 3f23fab..9e188ce 100644 (file)
@@ -834,6 +834,11 @@ class LanguageConverter {
 
                if ( strpos( $code, '/' ) === false ) {
                        $txt = $wgMessageCache->get( 'Conversiontable', true, $code );
+                       if( $txt === false ){
+                               # FIXME: this method doesn't seem to be expecting
+                               # this possible outcome...
+                               $txt = '&lt;Conversiontable&gt;';
+                       }
                } else {
                        $title = Title::makeTitleSafe( NS_MEDIAWIKI,
                                                                                   "Conversiontable/$code" );