r15827 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r15826‎ | r15827 | r15828 >
Date:08:26, 26 July 2006
Author:tstarling
Status:old
Tags:
Comment:
$wgLanguageCode no longer indicates the user language, for that use $wgLang->getCode(). This is necessary because determination of the language code is deferred.
Modified paths:
  • /trunk/phase3/includes/MessageCache.php (modified) (history)
  • /trunk/phase3/includes/QueryPage.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SpecialAllmessages.php (modified) (history)
  • /trunk/phase3/includes/StubObject.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/StubObject.php
@@ -102,20 +102,19 @@
103103 }
104104
105105 function _newObject() {
106 - global $wgLanguageCode, $wgContLanguageCode, $wgRequest, $wgUser, $wgContLang;
107 - // wgLanguageCode now specifically means the UI language
108 - $wgLanguageCode = $wgRequest->getText('uselang', '');
109 - if ($wgLanguageCode == '')
110 - $wgLanguageCode = $wgUser->getOption('language');
111 - # Validate $wgLanguageCode
112 - if( empty( $wgLanguageCode ) || !preg_match( '/^[a-z]+(-[a-z]+)?$/', $wgLanguageCode ) ) {
113 - $wgLanguageCode = $wgContLanguageCode;
 106+ global $wgContLanguageCode, $wgRequest, $wgUser, $wgContLang;
 107+ $code = $wgRequest->getText('uselang', '');
 108+ if ($code == '')
 109+ $code = $wgUser->getOption('language');
 110+ # Validate $code
 111+ if( empty( $code ) || !preg_match( '/^[a-z]+(-[a-z]+)?$/', $code ) ) {
 112+ $code = $wgContLanguageCode;
114113 }
115114
116 - if( $wgLanguageCode == $wgContLanguageCode ) {
 115+ if( $code == $wgContLanguageCode ) {
117116 return $wgContLang;
118117 } else {
119 - $obj = Language::factory( $wgLanguageCode );
 118+ $obj = Language::factory( $code );
120119 return $obj;
121120 }
122121 }
Index: trunk/phase3/includes/MessageCache.php
@@ -414,15 +414,13 @@
415415 }
416416
417417 function get( $key, $useDB = true, $forcontent = true, $isfullkey = false ) {
418 - global $wgContLanguageCode, $wgContLang;
 418+ global $wgContLanguageCode, $wgContLang, $wgLang;
419419 if( $forcontent ) {
420420 $lang =& $wgContLang;
421 - $langcode = $wgContLanguageCode;
422421 } else {
423 - global $wgLang, $wgLanguageCode;
424422 $lang =& $wgLang;
425 - $langcode = $wgLanguageCode;
426423 }
 424+ $langcode = $lang->getCode();
427425 # If uninitialised, someone is trying to call this halfway through Setup.php
428426 if( !$this->mInitialised ) {
429427 return '<' . htmlspecialchars($key) . '>';
Index: trunk/phase3/includes/Setup.php
@@ -82,6 +82,10 @@
8383 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
8484 }
8585
 86+# These are now the same, always
 87+# To determine the user language, use $wgLang->getCode()
 88+$wgContLanguageCode = $wgLanguageCode;
 89+
8690 wfProfileOut( $fname.'-misc1' );
8791 wfProfileIn( $fname.'-memcached' );
8892
@@ -133,11 +137,6 @@
134138 ));
135139 }
136140
137 -# $wgLanguageCode may be changed later to fit with user preference.
138 -# The content language will remain fixed as per the configuration,
139 -# so let's keep it.
140 -$wgContLanguageCode = $wgLanguageCode;
141 -
142141 $wgLoadBalancer = new StubObject( 'wgLoadBalancer', 'LoadBalancer',
143142 array( $wgDBservers, false, $wgMasterWaitTimeout, true ) );
144143 $wgContLang = new StubContLang;
Index: trunk/phase3/includes/SpecialAllmessages.php
@@ -62,10 +62,10 @@
6363 *
6464 */
6565 function makePhp($messages) {
66 - global $wgLanguageCode;
 66+ global $wgLang;
6767 $txt = "\n\n\$messages = array(\n";
6868 foreach( $messages as $key => $m ) {
69 - if(strtolower($wgLanguageCode) != 'en' and $m['msg'] == $m['enmsg'] ) {
 69+ if($wgLang->getCode() != 'en' and $m['msg'] == $m['enmsg'] ) {
7070 //if (strstr($m['msg'],"\n")) {
7171 // $txt.='/* ';
7272 // $comment=' */';
@@ -90,7 +90,7 @@
9191 *
9292 */
9393 function makeHTMLText( $messages ) {
94 - global $wgLang, $wgUser, $wgLanguageCode, $wgContLanguageCode;
 94+ global $wgLang, $wgContLang, $wgUser;
9595 $fname = "makeHTMLText";
9696 wfProfileIn( $fname );
9797
@@ -148,8 +148,8 @@
149149 foreach( $messages as $key => $m ) {
150150
151151 $title = $wgLang->ucfirst( $key );
152 - if($wgLanguageCode != $wgContLanguageCode)
153 - $title.="/$wgLanguageCode";
 152+ if($wgLang->getCode() != $wgContLang->getCode())
 153+ $title.= '/' . $wgLang->getCode();
154154
155155 $titleObj =& Title::makeTitle( NS_MEDIAWIKI, $title );
156156 $talkPage =& Title::makeTitle( NS_MEDIAWIKI_TALK, $title );
Index: trunk/phase3/includes/QueryPage.php
@@ -448,10 +448,10 @@
449449 }
450450
451451 function feedTitle() {
452 - global $wgLanguageCode, $wgSitename;
 452+ global $wgContLanguageCode, $wgSitename;
453453 $page = SpecialPage::getPage( $this->getName() );
454454 $desc = $page->getDescription();
455 - return "$wgSitename - $desc [$wgLanguageCode]";
 455+ return "$wgSitename - $desc [$wgContLanguageCode]";
456456 }
457457
458458 function feedDesc() {
Index: trunk/phase3/includes/Skin.php
@@ -1438,7 +1438,7 @@
14391439 */
14401440 function buildSidebar() {
14411441 global $wgDBname, $parserMemc, $wgEnableSidebarCache;
1442 - global $wgLanguageCode, $wgContLanguageCode;
 1442+ global $wgLang, $wgContLang;
14431443
14441444 $fname = 'SkinTemplate::buildSidebar';
14451445
@@ -1446,7 +1446,7 @@
14471447
14481448 $key = "{$wgDBname}:sidebar";
14491449 $cacheSidebar = $wgEnableSidebarCache &&
1450 - ($wgLanguageCode == $wgContLanguageCode);
 1450+ ($wgLang->getCode() == $wgContLang->getCode());
14511451
14521452 if ($cacheSidebar) {
14531453 $cachedsidebar = $parserMemc->get( $key );

Follow-up revisions

RevisionCommit summaryAuthorDate
r72561Remove $wgContLanguageCode usage in core....platonides22:37, 7 September 2010