Merge "Make MessageCache::load() require a language code"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 19 Oct 2016 01:38:43 +0000 (01:38 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 19 Oct 2016 01:38:43 +0000 (01:38 +0000)
includes/cache/MessageCache.php
languages/LanguageConverter.php

index 48a13c5..f676deb 100644 (file)
@@ -228,17 +228,14 @@ class MessageCache {
         * or false if populating empty cache fails. Also returns true if MessageCache
         * is disabled.
         *
-        * @param bool|string $code Language to which load messages
-        * @param integer $mode Use MessageCache::FOR_UPDATE to skip process cache
+        * @param string $code Language to which load messages
+        * @param integer $mode Use MessageCache::FOR_UPDATE to skip process cache [optional]
         * @throws MWException
         * @return bool
         */
-       function load( $code = false, $mode = null ) {
+       protected function load( $code, $mode = null ) {
                if ( !is_string( $code ) ) {
-                       # This isn't really nice, so at least make a note about it and try to
-                       # fall back
-                       wfDebug( __METHOD__ . " called without providing a language code\n" );
-                       $code = 'en';
+                       throw new InvalidArgumentException( "Missing language code" );
                }
 
                # Don't do double loading...
@@ -865,6 +862,8 @@ class MessageCache {
                                }
                                $alreadyTried[ $langcode ] = true;
                        }
+               } else {
+                       $uckey = null;
                }
 
                // Check the CDB cache
@@ -882,7 +881,8 @@ class MessageCache {
                                        continue;
                                }
 
-                               $message = $this->getMsgFromNamespace( $this->getMessagePageName( $code, $uckey ), $code );
+                               $message = $this->getMsgFromNamespace(
+                                       $this->getMessagePageName( $code, $uckey ), $code );
 
                                if ( $message !== false ) {
                                        return $message;
index 1c003ad..5a9f652 100644 (file)
@@ -48,7 +48,9 @@ class LanguageConverter {
        ];
 
        public $mMainLanguageCode;
-       public $mVariants, $mVariantFallbacks, $mVariantNames;
+       public $mVariants;
+       public $mVariantFallbacks;
+       public $mVariantNames;
        public $mTablesLoaded = false;
        public $mTables;
        // 'bidirectional' 'unidirectional' 'disable' for each variant