Fix language statistics after messages have been moved to JSON
authorAlexandre Emsenhuber <mediawiki@emsenhuber.ch>
Wed, 2 Apr 2014 18:05:51 +0000 (20:05 +0200)
committerAlexandre Emsenhuber <mediawiki@emsenhuber.ch>
Wed, 2 Apr 2014 18:05:51 +0000 (20:05 +0200)
Statistics are now showing always no messages since languages.inc
does not manage to load the JSON messages.

Had to make LocalisationCache::readJSONFile() public so that it can
be used in  languages.inc; since all methods from LocalisationCache
return localisations merged with fallbacks, which is not what we
want here.

Fix for I918cfdc46c (0dd91d5).

Change-Id: Ib52287db618b9d072e847130070d165a3e7ae44b

includes/cache/LocalisationCache.php
maintenance/language/languages.inc

index 8827219..b89316b 100644 (file)
@@ -539,7 +539,7 @@ class LocalisationCache {
         * @throws MWException if there is a syntax error in the JSON file
         * @return array with a 'messages' key, or empty array if the file doesn't exist
         */
-       protected function readJSONFile( $fileName ) {
+       public function readJSONFile( $fileName ) {
                wfProfileIn( __METHOD__ );
 
                if ( !is_readable( $fileName ) ) {
index 61ee424..0483aea 100644 (file)
@@ -125,12 +125,16 @@ class Languages {
                $this->mNamespaceAliases[$code] = array();
                $this->mMagicWords[$code] = array();
                $this->mSpecialPageAliases[$code] = array();
+
+               $jsonfilename = Language::getJsonMessagesFileName( $code );
+               if ( file_exists( $jsonfilename ) ) {
+                       $json = Language::getLocalisationCache()->readJSONFile( $jsonfilename );
+                       $this->mRawMessages[$code] = $json['messages'];
+               }
+
                $filename = Language::getMessagesFileName( $code );
                if ( file_exists( $filename ) ) {
                        require $filename;
-                       if ( isset( $messages ) ) {
-                               $this->mRawMessages[$code] = $messages;
-                       }
                        if ( isset( $fallback ) ) {
                                $this->mFallback[$code] = $fallback;
                        }