Fix profiling error in LocalisationCache::readJSONFile()
authorAlexandre Emsenhuber <mediawiki@emsenhuber.ch>
Tue, 18 Mar 2014 08:41:45 +0000 (09:41 +0100)
committerAlexandre Emsenhuber <mediawiki@emsenhuber.ch>
Tue, 18 Mar 2014 08:41:45 +0000 (09:41 +0100)
Follow-up I8d137e15e1 (6380e81).

Also added more blank lines for better readability.

Change-Id: Iae7921b017f81d5512e71384d7999502154c034c

includes/cache/LocalisationCache.php

index 409160c..c56111f 100644 (file)
@@ -541,18 +541,27 @@ class LocalisationCache {
         */
        protected function readJSONFile( $fileName ) {
                wfProfileIn( __METHOD__ );
+
                if ( !is_readable( $fileName ) ) {
+                       wfProfileOut( __METHOD__ );
+
                        return array();
                }
 
                $json = file_get_contents( $fileName );
                if ( $json === false ) {
+                       wfProfileOut( __METHOD__ );
+
                        return array();
                }
+
                $data = FormatJson::decode( $json, true );
                if ( $data === null ) {
+                       wfProfileOut( __METHOD__ );
+
                        throw new MWException( __METHOD__ . ": Invalid JSON file: $fileName" );
                }
+
                // Remove keys starting with '@', they're reserved for metadata and non-message data
                foreach ( $data as $key => $unused ) {
                        if ( $key === '' || $key[0] === '@' ) {
@@ -560,6 +569,8 @@ class LocalisationCache {
                        }
                }
 
+               wfProfileOut( __METHOD__ );
+
                // The JSON format only supports messages, none of the other variables, so wrap the data
                return array( 'messages' => $data );
        }