https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113024
Revision: 113024
Author: tstarling
Date: 2012-03-05 12:14:53 +0000 (Mon, 05 Mar 2012)
Log Message:
-----------
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
trunk/phase3/includes/parser/Parser.php
Modified: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php 2012-03-05 12:10:32 UTC (rev
113023)
+++ trunk/phase3/includes/DefaultSettings.php 2012-03-05 12:14:53 UTC (rev
113024)
@@ -2178,6 +2178,17 @@
*/
$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
/*************************************************************************//**
Modified: trunk/phase3/includes/parser/Parser.php
===================================================================
--- trunk/phase3/includes/parser/Parser.php 2012-03-05 12:10:32 UTC (rev
113023)
+++ trunk/phase3/includes/parser/Parser.php 2012-03-05 12:14:53 UTC (rev
113024)
@@ -370,13 +370,16 @@
*/
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 @@
|| 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 );
}
}
@@ -717,6 +720,18 @@
}
/**
+ * 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 @@
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 @@
list( $dtrail, $trail ) = Linker::splitTrail(
$trail );
}
- $text = $this->getTargetLanguage()->markNoConversion(
$text );
+ $text =
$this->getConverterLanguage()->markNoConversion( $text );
$url = Sanitizer::cleanUrl( $url );
@@ -1716,8 +1731,8 @@
$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 @@
}
$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 @@
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();
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs