r113024 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113023‎ | r113024 | r113025 >
Date:12:14, 5 March 2012
Author:tstarling
Status:ok
Tags:
Comment:
Transitional patch for bug 34832: introduce a CI-style option to allow deployment of 1.19 to converter wikis without disruption. The bug fix can be rolled out later by setting $wgBug34832TransitionalRollback = false. This is meant as a temporary measure, while we figure out a way to properly support Chinese wikis for inclusion in the 1.19 tarball.

Introduce a global variable which causes language conversion to not be disabled in interface messages (as before r94279). Use $wgContLang for conversion (as before r97849) since $wgContLang is set to the base language (e.g. zh) on converter wikis, whereas a typical user language (e.g. zh-tw) only has a FakeConverter.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -370,13 +370,16 @@
371371 */
372372 if ( !( $wgDisableLangConversion
373373 || isset( $this->mDoubleUnderscores['nocontentconvert'] )
374 - || $this->mTitle->isConversionTable()
375 - || $this->mOptions->getInterfaceMessage() ) ) {
376 -
377 - # The position of the convert() call should not be changed. it
378 - # assumes that the links are all replaced and the only thing left
379 - # is the <nowiki> mark.
380 - $text = $this->getTargetLanguage()->convert( $text );
 374+ || $this->mTitle->isConversionTable() ) )
 375+ {
 376+ # Run convert unconditionally in 1.18-compatible mode
 377+ global $wgBug34832TransitionalRollback;
 378+ if ( $wgBug34832TransitionalRollback || !$this->mOptions->getInterfaceMessage() ) {
 379+ # The position of the convert() call should not be changed. it
 380+ # assumes that the links are all replaced and the only thing left
 381+ # is the <nowiki> mark.
 382+ $text = $this->getConverterLanguage()->convert( $text );
 383+ }
381384 }
382385
383386 /**
@@ -392,11 +395,11 @@
393396 || isset( $this->mDoubleUnderscores['notitleconvert'] )
394397 || $this->mOutput->getDisplayTitle() !== false ) )
395398 {
396 - $convruletitle = $this->getTargetLanguage()->getConvRuleTitle();
 399+ $convruletitle = $this->getConverterLanguage()->getConvRuleTitle();
397400 if ( $convruletitle ) {
398401 $this->mOutput->setTitleText( $convruletitle );
399402 } else {
400 - $titleText = $this->getTargetLanguage()->convertTitle( $title );
 403+ $titleText = $this->getConverterLanguage()->convertTitle( $title );
401404 $this->mOutput->setTitleText( $titleText );
402405 }
403406 }
@@ -717,6 +720,18 @@
718721 }
719722
720723 /**
 724+ * Get the language object for language conversion
 725+ */
 726+ function getConverterLanguage() {
 727+ global $wgBug34832TransitionalRollback, $wgContLang;
 728+ if ( $wgBug34832TransitionalRollback ) {
 729+ return $wgContLang;
 730+ } else {
 731+ return $this->getTargetLanguage();
 732+ }
 733+ }
 734+
 735+ /**
721736 * Get a User object either from $this->mUser, if set, or from the
722737 * ParserOptions object otherwise
723738 *
@@ -1237,7 +1252,7 @@
12381253 if ( $text === false ) {
12391254 # Not an image, make a link
12401255 $text = Linker::makeExternalLink( $url,
1241 - $this->getTargetLanguage()->markNoConversion($url), true, 'free',
 1256+ $this->getConverterLanguage()->markNoConversion($url), true, 'free',
12421257 $this->getExternalLinkAttribs( $url ) );
12431258 # Register it in the output object...
12441259 # Replace unnecessary URL escape codes with their equivalent characters
@@ -1510,7 +1525,7 @@
15111526 list( $dtrail, $trail ) = Linker::splitTrail( $trail );
15121527 }
15131528
1514 - $text = $this->getTargetLanguage()->markNoConversion( $text );
 1529+ $text = $this->getConverterLanguage()->markNoConversion( $text );
15151530
15161531 $url = Sanitizer::cleanUrl( $url );
15171532
@@ -1716,8 +1731,8 @@
17171732 $prefix = '';
17181733 }
17191734
1720 - if ( $this->getTargetLanguage()->hasVariants() ) {
1721 - $selflink = $this->getTargetLanguage()->autoConvertToAllVariants(
 1735+ if ( $this->getConverterLanguage()->hasVariants() ) {
 1736+ $selflink = $this->getConverterLanguage()->autoConvertToAllVariants(
17221737 $this->mTitle->getPrefixedText() );
17231738 } else {
17241739 $selflink = array( $this->mTitle->getPrefixedText() );
@@ -1936,7 +1951,7 @@
19371952 }
19381953 $sortkey = Sanitizer::decodeCharReferences( $sortkey );
19391954 $sortkey = str_replace( "\n", '', $sortkey );
1940 - $sortkey = $this->getTargetLanguage()->convertCategoryKey( $sortkey );
 1955+ $sortkey = $this->getConverterLanguage()->convertCategoryKey( $sortkey );
19411956 $this->mOutput->addCategory( $nt->getDBkey(), $sortkey );
19421957
19431958 /**
@@ -3214,8 +3229,8 @@
32153230 if ( $title ) {
32163231 $titleText = $title->getPrefixedText();
32173232 # Check for language variants if the template is not found
3218 - if ( $this->getTargetLanguage()->hasVariants() && $title->getArticleID() == 0 ) {
3219 - $this->getTargetLanguage()->findVariantLink( $part1, $title, true );
 3233+ if ( $this->getConverterLanguage()->hasVariants() && $title->getArticleID() == 0 ) {
 3234+ $this->getConverterLanguage()->findVariantLink( $part1, $title, true );
32203235 }
32213236 # Do recursion depth check
32223237 $limit = $this->mOptions->getMaxTemplateDepth();
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2178,6 +2178,17 @@
21792179 */
21802180 $wgLocalTZoffset = null;
21812181
 2182+/**
 2183+ * If set to true, this will roll back a few bug fixes introduced in 1.19,
 2184+ * emulating the 1.18 behaviour, to avoid introducing bug 34832. In 1.19,
 2185+ * language variant conversion is disabled in interface messages. Setting this
 2186+ * to true re-enables it.
 2187+ *
 2188+ * This variable should be removed (implicitly false) in 1.20 or earlier.
 2189+ */
 2190+$wgBug34832TransitionalRollback = true;
 2191+
 2192+
21822193 /** @} */ # End of language/charset settings
21832194
21842195 /*************************************************************************//**

Follow-up revisions

RevisionCommit summaryAuthorDate
r113119MFT r112872, r112873, r113001, r113024: language converter fixeststarling02:09, 6 March 2012
r113157MFT r112563, r112566, r112838, r112872, r112873, r112988, r113001, r113024, r...reedy17:36, 6 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94279* CategoryPage.php: fix the "category-empty" message per comment on r91518, i...robin19:58, 11 August 2011
r97849Re-do r96798 ("LanguageConverter now depends on the page content language"), ...robin20:31, 22 September 2011
r112872Fix for r86304: if MessageCache::parse() is called twice, once with $interfac...tstarling04:00, 2 March 2012
r112873(bug 34832) Parse recentchangestext with the interface option off, since it c...tstarling04:52, 2 March 2012

Status & tagging log