From 5de9529eb169e42e1649a38a3a07c8f6b72aeaa7 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Mon, 29 Nov 2004 12:36:43 +0000 Subject: [PATCH] made connection errors work again --- includes/GlobalFunctions.php | 28 ++++++++++++++++------------ includes/Setup.php | 11 +++++++---- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index d4e2c9bf24..f05e82dd28 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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 = "<$key>"; } # Replace arguments diff --git a/includes/Setup.php b/includes/Setup.php index a2eefdbdf8..07cd890e42 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -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 ) ); -- 2.20.1