r55746 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55745‎ | r55746 | r55747 >
Date:07:19, 2 September 2009
Author:tstarling
Status:ok
Tags:
Comment:
Fixes for r51204: removed useless $wgVariant and StubUserVariant. In Skin::makeGlobalVariablesScript(), use $wgContLang->getPreferredVariant() instead, which is the variant used in the relevant server-side code.
Modified paths:
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/StubObject.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/StubObject.php
@@ -167,53 +167,6 @@
168168 }
169169
170170 /**
171 - * Stub object for the user variant. It depends of the user preferences and
172 - * "variant" parameter that can be passed to index.php. This object have to be
173 - * in $wgVariant global.
174 - */
175 -class StubUserVariant extends StubObject {
176 -
177 - function __construct() {
178 - parent::__construct( 'wgVariant' );
179 - }
180 -
181 - function __call( $name, $args ) {
182 - return $this->_call( $name, $args );
183 - }
184 -
185 - function _newObject() {
186 - global $wgContLanguageCode, $wgRequest, $wgUser, $wgContLang;
187 -
188 - if( $wgContLang->hasVariants() ) {
189 - $code = $wgRequest->getVal( 'variant', $wgUser->getOption( 'variant' ) );
190 - } else {
191 - $code = $wgRequest->getVal( 'variant', $wgUser->getOption( 'language' ) );
192 - }
193 -
194 - // if variant is explicitely selected, use it instead the one from wgUser
195 - // see bug #7605
196 - if( $wgContLang->hasVariants() && in_array($code, $wgContLang->getVariants()) ){
197 - $variant = $wgContLang->getPreferredVariant();
198 - if( $variant != $wgContLanguageCode )
199 - $code = $variant;
200 - }
201 -
202 - # Validate $code
203 - if( empty( $code ) || !preg_match( '/^[a-z-]+$/', $code ) || ( $code === 'qqq' ) ) {
204 - wfDebug( "Invalid user variant code\n" );
205 - $code = $wgContLanguageCode;
206 - }
207 -
208 - if( $code === $wgContLanguageCode ) {
209 - return $wgContLang;
210 - } else {
211 - $obj = Language::factory( $code );
212 - return $obj;
213 - }
214 - }
215 -}
216 -
217 -/**
218171 * Stub object for the user. The initialisation of the will depend of
219172 * $wgCommandLineMode. If it's true, it will be an anonymous user and if it's
220173 * false, the user will be loaded from credidentails provided by cookies. This
Index: trunk/phase3/includes/Setup.php
@@ -270,7 +270,6 @@
271271
272272 $wgUser = new StubUser;
273273 $wgLang = new StubUserLang;
274 -$wgVariant = new StubUserVariant;
275274 $wgOut = new StubObject( 'wgOut', 'OutputPage' );
276275 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
277276
Index: trunk/phase3/includes/Skin.php
@@ -356,7 +356,7 @@
357357 $skinName = $skinName['skinname'];
358358 }
359359 global $wgScript, $wgTitle, $wgStylePath, $wgUser;
360 - global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang, $wgVariant;
 360+ global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
361361 global $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
362362 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
363363 global $wgUseAjax, $wgAjaxWatch;
@@ -399,7 +399,6 @@
400400 'wgIsArticle' => $wgOut->isArticle(),
401401 'wgUserName' => $wgUser->isAnon() ? NULL : $wgUser->getName(),
402402 'wgUserGroups' => $wgUser->isAnon() ? NULL : $wgUser->getEffectiveGroups(),
403 - 'wgUserVariant' => $wgVariant->getCode(),
404403 'wgUserLanguage' => $wgLang->getCode(),
405404 'wgContentLanguage' => $wgContLang->getCode(),
406405 'wgBreakFrames' => $wgBreakFrames,
@@ -411,8 +410,8 @@
412411 'wgDigitTransformTable' => $compactDigitTransTable,
413412 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null,
414413 );
415 - if ( !( $wgContLang->hasVariants() ) ) {
416 - unset( $vars['wgUserVariant'] );
 414+ if ( $wgContLang->hasVariants() ) {
 415+ $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
417416 }
418417
419418 //if on upload page output the extension list & js_upload

Follow-up revisions

RevisionCommit summaryAuthorDate
r63066Remove $wgVariant from HISTORY, Tim removed it in r55746. Will backport to 1....demon12:32, 28 February 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r51204* (bug 10837) Introducing the StubUserVariant class to determine the variant ...shinjiman19:49, 30 May 2009

Status & tagging log