Remove unnecessary conditional
[lhc/web/wiklou.git] / includes / MessageCache.php
index f24d3b4..0f2fc22 100644 (file)
@@ -44,7 +44,6 @@ class MessageCache {
 
        /**
         * ParserOptions is lazy initialised.
-        * Access should probably be protected.
         */
        function getParserOptions() {
                if ( !$this->mParserOptions ) {
@@ -110,7 +109,7 @@ class MessageCache {
                global $wgLocalMessageCache;
 
                $filename = "$wgLocalMessageCache/messages-" . wfWikiID() . "-$code";
-               wfMkdirParents( $wgLocalMessageCache, 0777 ); // might fail
+               wfMkdirParents( $wgLocalMessageCache ); // might fail
 
                wfSuppressWarnings();
                $file = fopen( $filename, 'w' );
@@ -131,7 +130,7 @@ class MessageCache {
 
                $filename = "$wgLocalMessageCache/messages-" . wfWikiID() . "-$code";
                $tempFilename = $filename . '.tmp';
-       wfMkdirParents( $wgLocalMessageCache, 0777 ); // might fail
+               wfMkdirParents( $wgLocalMessageCache ); // might fail
 
                wfSuppressWarnings();
                $file = fopen( $tempFilename, 'w');
@@ -498,29 +497,9 @@ class MessageCache {
         * @param bool $isFullKey Specifies whether $key is a two part key "lang/msg".
         */
        function get( $key, $useDB = true, $langcode = true, $isFullKey = false ) {
-               global $wgContLanguageCode, $wgContLang, $wgLang;
-
-               # Identify which language to get or create a language object for.
-               if( $langcode === $wgContLang->getCode() || $langcode === true ) {
-                       # $langcode is the language code of the wikis content language object.
-                       # or it is a boolean and value is true
-                       $lang =& $wgContLang;
-               } elseif( $langcode === $wgLang->getCode() || $langcode === false ) {
-                       # $langcode is the language code of user language object.
-                       # or it was a boolean and value is false
-                       $lang =& $wgLang;
-               } else {
-                       $validCodes = array_keys( Language::getLanguageNames() );
-                       if( in_array( $langcode, $validCodes ) ) {
-                               # $langcode corresponds to a valid language.
-                               $lang = Language::factory( $langcode );
-                       } else {
-                               # $langcode is a string, but not a valid language code; use content language.
-                               $lang =& $wgContLang;
-                               wfDebug( 'Invalid language code passed to MessageCache::get, falling back to content language.' );
-                       }
-               }
+               global $wgContLanguageCode, $wgContLang;
 
+               $lang = wfGetLangObj( $langcode );
                $langcode = $lang->getCode();
 
                # If uninitialised, someone is trying to call this halfway through Setup.php
@@ -670,12 +649,18 @@ class MessageCache {
                        return $message;
                }
 
-               global $wgParser;
+               global $wgParser, $wgParserConf;
                if ( !$this->mParser && isset( $wgParser ) ) {
                        # Do some initialisation so that we don't have to do it twice
                        $wgParser->firstCallInit();
                        # Clone it and store it
-                       $this->mParser = clone $wgParser;
+                       $class = $wgParserConf['class'];
+                       if ( $class == 'Parser_DiffTest' ) {
+                               # Uncloneable
+                               $this->mParser = new $class( $wgParserConf );
+                       } else {
+                               $this->mParser = clone $wgParser;
+                       }
                        #wfDebug( __METHOD__ . ": following contents triggered transform: $message\n" );
                }
                if ( $this->mParser ) {