From 561424c266128a8c2c213cd803d4786313fc20cc Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Mon, 5 Mar 2012 12:14:53 +0000 Subject: [PATCH] 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. --- includes/DefaultSettings.php | 11 +++++++++ includes/parser/Parser.php | 47 ++++++++++++++++++++++++------------ 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 1b43d0cd68..827a094012 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2178,6 +2178,17 @@ $wgLocaltimezone = null; */ $wgLocalTZoffset = null; +/** + * If set to true, this will roll back a few bug fixes introduced in 1.19, + * emulating the 1.18 behaviour, to avoid introducing bug 34832. In 1.19, + * language variant conversion is disabled in interface messages. Setting this + * to true re-enables it. + * + * This variable should be removed (implicitly false) in 1.20 or earlier. + */ +$wgBug34832TransitionalRollback = true; + + /** @} */ # End of language/charset settings /*************************************************************************//** diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 7d60ae7516..de71d29abd 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -370,13 +370,16 @@ class Parser { */ if ( !( $wgDisableLangConversion || isset( $this->mDoubleUnderscores['nocontentconvert'] ) - || $this->mTitle->isConversionTable() - || $this->mOptions->getInterfaceMessage() ) ) { - - # The position of the convert() call should not be changed. it - # assumes that the links are all replaced and the only thing left - # is the mark. - $text = $this->getTargetLanguage()->convert( $text ); + || $this->mTitle->isConversionTable() ) ) + { + # Run convert unconditionally in 1.18-compatible mode + global $wgBug34832TransitionalRollback; + if ( $wgBug34832TransitionalRollback || !$this->mOptions->getInterfaceMessage() ) { + # The position of the convert() call should not be changed. it + # assumes that the links are all replaced and the only thing left + # is the mark. + $text = $this->getConverterLanguage()->convert( $text ); + } } /** @@ -392,11 +395,11 @@ class Parser { || isset( $this->mDoubleUnderscores['notitleconvert'] ) || $this->mOutput->getDisplayTitle() !== false ) ) { - $convruletitle = $this->getTargetLanguage()->getConvRuleTitle(); + $convruletitle = $this->getConverterLanguage()->getConvRuleTitle(); if ( $convruletitle ) { $this->mOutput->setTitleText( $convruletitle ); } else { - $titleText = $this->getTargetLanguage()->convertTitle( $title ); + $titleText = $this->getConverterLanguage()->convertTitle( $title ); $this->mOutput->setTitleText( $titleText ); } } @@ -716,6 +719,18 @@ class Parser { return $this->mTitle->getPageLanguage(); } + /** + * Get the language object for language conversion + */ + function getConverterLanguage() { + global $wgBug34832TransitionalRollback, $wgContLang; + if ( $wgBug34832TransitionalRollback ) { + return $wgContLang; + } else { + return $this->getTargetLanguage(); + } + } + /** * Get a User object either from $this->mUser, if set, or from the * ParserOptions object otherwise @@ -1237,7 +1252,7 @@ class Parser { if ( $text === false ) { # Not an image, make a link $text = Linker::makeExternalLink( $url, - $this->getTargetLanguage()->markNoConversion($url), true, 'free', + $this->getConverterLanguage()->markNoConversion($url), true, 'free', $this->getExternalLinkAttribs( $url ) ); # Register it in the output object... # Replace unnecessary URL escape codes with their equivalent characters @@ -1510,7 +1525,7 @@ class Parser { list( $dtrail, $trail ) = Linker::splitTrail( $trail ); } - $text = $this->getTargetLanguage()->markNoConversion( $text ); + $text = $this->getConverterLanguage()->markNoConversion( $text ); $url = Sanitizer::cleanUrl( $url ); @@ -1716,8 +1731,8 @@ class Parser { $prefix = ''; } - if ( $this->getTargetLanguage()->hasVariants() ) { - $selflink = $this->getTargetLanguage()->autoConvertToAllVariants( + if ( $this->getConverterLanguage()->hasVariants() ) { + $selflink = $this->getConverterLanguage()->autoConvertToAllVariants( $this->mTitle->getPrefixedText() ); } else { $selflink = array( $this->mTitle->getPrefixedText() ); @@ -1936,7 +1951,7 @@ class Parser { } $sortkey = Sanitizer::decodeCharReferences( $sortkey ); $sortkey = str_replace( "\n", '', $sortkey ); - $sortkey = $this->getTargetLanguage()->convertCategoryKey( $sortkey ); + $sortkey = $this->getConverterLanguage()->convertCategoryKey( $sortkey ); $this->mOutput->addCategory( $nt->getDBkey(), $sortkey ); /** @@ -3214,8 +3229,8 @@ class Parser { if ( $title ) { $titleText = $title->getPrefixedText(); # Check for language variants if the template is not found - if ( $this->getTargetLanguage()->hasVariants() && $title->getArticleID() == 0 ) { - $this->getTargetLanguage()->findVariantLink( $part1, $title, true ); + if ( $this->getConverterLanguage()->hasVariants() && $title->getArticleID() == 0 ) { + $this->getConverterLanguage()->findVariantLink( $part1, $title, true ); } # Do recursion depth check $limit = $this->mOptions->getMaxTemplateDepth(); -- 2.20.1