Transitional patch for bug 34832: introduce a CI-style option to allow deployment...
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 5 Mar 2012 12:14:53 +0000 (12:14 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 5 Mar 2012 12:14:53 +0000 (12:14 +0000)
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
includes/parser/Parser.php

index 1b43d0c..827a094 100644 (file)
@@ -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
 
 /*************************************************************************//**
index 7d60ae7..de71d29 100644 (file)
@@ -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 <nowiki> 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 <nowiki> 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();