made connection errors work again
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 29 Nov 2004 12:36:43 +0000 (12:36 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 29 Nov 2004 12:36:43 +0000 (12:36 +0000)
includes/GlobalFunctions.php
includes/Setup.php

index d4e2c9b..f05e82d 100644 (file)
@@ -370,10 +370,11 @@ function wfMsgReal( $key, $args, $useDB, $forContent=false ) {
        static $replacementKeys = array( '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9' );
        global $wgParser, $wgMsgParserOptions;
        global $wgContLang, $wgLanguageCode;
+       global $wgMessageCache, $wgLang;
        
        $fname = 'wfMsgReal';
        wfProfileIn( $fname );
-       
+
        if( $forContent ) {
                /**
                 * Message is needed for page content, and needs
@@ -383,7 +384,6 @@ function wfMsgReal( $key, $args, $useDB, $forContent=false ) {
                 * parser cache and be served back to other 
                 * visitors.
                 */
-               global $wgMessageCache;
                $cache = &$wgMessageCache;
                $lang = &$wgContLang;
        } else {
@@ -393,21 +393,28 @@ function wfMsgReal( $key, $args, $useDB, $forContent=false ) {
                 * language variant or a separate user interface
                 * language; if so use that.
                 */
-               if( in_array( $wgLanguageCode, $wgContLang->getVariants() ) ) {
-                       global $wgLang, $wgMessageCache;
-                       $cache = &$wgMessageCache;
-                       $lang = &$wgLang;
+               if ( is_object( $wgContLang ) ) {
+                       if( in_array( $wgLanguageCode, $wgContLang->getVariants() ) ) {
+                               $cache = &$wgMessageCache;
+                               $lang = &$wgLang;
+                       } else {
+                               $cache = false;
+                               $lang = &$wgLang;
+                       }
                } else {
-                       global $wgLang;
                        $cache = false;
-                       $lang = &$wgLang;
+                       $lang = false;
                }
        }
 
 
        if( is_object( $cache ) ) {
                $message = $cache->get( $key, $useDB, $forContent );
-       } elseif( is_object( $lang ) ) {
+       } else {
+               if ( !is_object( $lang ) ) {
+                       $lang = new Language;
+               }
+       
                wfSuppressWarnings();
                $message = $lang->getMessage( $key );
                wfRestoreWarnings();
@@ -416,9 +423,6 @@ function wfMsgReal( $key, $args, $useDB, $forContent=false ) {
                if(strstr($message, '{{' ) !== false) {
                        $message = $wgParser->transformMsg($message, $wgMsgParserOptions);
                }
-       } else {
-               wfDebug( "No language object when getting $key\n" );
-               $message = "&lt;$key&gt;";
        }
 
        # Replace arguments
index a2eefdb..07cd890 100644 (file)
@@ -209,6 +209,11 @@ $wgLoadBalancer = LoadBalancer::newFromParams( $wgDBservers );
 $wgLoadBalancer->loadMasterPos();
 
 wfProfileOut( $fname.'-database' );
+wfProfileIn( $fname.'-language1' );
+
+require_once( "$IP/languages/Language.php" );
+
+wfProfileOut( $fname.'-language1' );
 wfProfileIn( $fname.'-User' );
 
 # Skin setup functions
@@ -232,7 +237,7 @@ if( $wgCommandLineMode ) {
 }
 
 wfProfileOut( $fname.'-User' );
-wfProfileIn( $fname.'-language' );
+wfProfileIn( $fname.'-language2' );
 
 function setupLangObj(&$langclass, $langcode) {
        global $wgUseLatin1, $IP;
@@ -259,8 +264,6 @@ function setupLangObj(&$langclass, $langcode) {
        return $lang;
 }
 
-require_once( "$IP/languages/Language.php" );
-
 # $wgLanguageCode may be changed later to fit with user preference.
 # The content language will remain fixed as per the configuration,
 # so let's keep it.
@@ -276,7 +279,7 @@ if( !$wgUser->mDataLoaded ) {
 }
 
 // wgLanguageCode now specifically means the UI language
-$wgLanguageCode = $wgUser->getOption('language');
+$wgLanguageCode = $wgUser->getOption('language2');
 
 $wgLangClass = 'Language'. str_replace( '-', '_', ucfirst( $wgLanguageCode ) );