https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113119
Revision: 113119
Author: tstarling
Date: 2012-03-06 02:09:48 +0000 (Tue, 06 Mar 2012)
Log Message:
-----------
MFT r112872, r112873, r113001, r113024: language converter fixes
Modified Paths:
--------------
branches/wmf/1.19wmf1/includes/DefaultSettings.php
branches/wmf/1.19wmf1/includes/cache/MessageCache.php
branches/wmf/1.19wmf1/includes/parser/Parser.php
branches/wmf/1.19wmf1/includes/specials/SpecialRecentchanges.php
Property Changed:
----------------
branches/wmf/1.19wmf1/includes/cache/MessageCache.php
Modified: branches/wmf/1.19wmf1/includes/DefaultSettings.php
===================================================================
--- branches/wmf/1.19wmf1/includes/DefaultSettings.php 2012-03-06 01:24:10 UTC
(rev 113118)
+++ branches/wmf/1.19wmf1/includes/DefaultSettings.php 2012-03-06 02:09:48 UTC
(rev 113119)
@@ -2177,6 +2177,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: branches/wmf/1.19wmf1/includes/cache/MessageCache.php
===================================================================
--- branches/wmf/1.19wmf1/includes/cache/MessageCache.php 2012-03-06
01:24:10 UTC (rev 113118)
+++ branches/wmf/1.19wmf1/includes/cache/MessageCache.php 2012-03-06
02:09:48 UTC (rev 113119)
@@ -833,14 +833,9 @@
$parser = $this->getParser();
$popts = $this->getParserOptions();
+ $popts->setInterfaceMessage( $interface );
+ $popts->setTargetLanguage( $language );
- if ( $interface ) {
- $popts->setInterfaceMessage( true );
- }
- if ( $language !== null ) {
- $popts->setTargetLanguage( $language );
- }
-
wfProfileIn( __METHOD__ );
if ( !$title || !$title instanceof Title ) {
global $wgTitle;
Property changes on: branches/wmf/1.19wmf1/includes/cache/MessageCache.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/JSTesting/includes/cache/MessageCache.php:100352-107913
/branches/REL1_15/phase3/includes/cache/MessageCache.php:51646
/branches/new-installer/phase3/includes/cache/MessageCache.php:43664-66004
/branches/sqlite/includes/cache/MessageCache.php:58211-58321
/branches/wmf/1.17wmf1/includes/MessageCache.php:82361
/branches/wmf/1.18wmf1/includes/cache/MessageCache.php:97508
/branches/wmf-deployment/includes/cache/MessageCache.php:53381
+ /branches/JSTesting/includes/cache/MessageCache.php:100352-107913
/branches/REL1_15/phase3/includes/cache/MessageCache.php:51646
/branches/new-installer/phase3/includes/cache/MessageCache.php:43664-66004
/branches/sqlite/includes/cache/MessageCache.php:58211-58321
/branches/wmf/1.17wmf1/includes/MessageCache.php:82361
/branches/wmf/1.18wmf1/includes/cache/MessageCache.php:97508
/branches/wmf-deployment/includes/cache/MessageCache.php:53381
/trunk/phase3/includes/cache/MessageCache.php:112872-112873,113001,113024
Modified: branches/wmf/1.19wmf1/includes/parser/Parser.php
===================================================================
--- branches/wmf/1.19wmf1/includes/parser/Parser.php 2012-03-06 01:24:10 UTC
(rev 113118)
+++ branches/wmf/1.19wmf1/includes/parser/Parser.php 2012-03-06 02:09:48 UTC
(rev 113119)
@@ -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->getFunctionLang()->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->getFunctionLang()->getConvRuleTitle();
+ $convruletitle =
$this->getConverterLanguage()->getConvRuleTitle();
if ( $convruletitle ) {
$this->mOutput->setTitleText( $convruletitle );
} else {
- $titleText =
$this->getFunctionLang()->convertTitle( $title );
+ $titleText =
$this->getConverterLanguage()->convertTitle( $title );
$this->mOutput->setTitleText( $titleText );
}
}
@@ -692,9 +695,18 @@
}
/**
+ * Get a language object for use in parser functions such as
{{FORMATNUM:}}
* @return Language
*/
function getFunctionLang() {
+ return $this->getTargetLanguage();
+ }
+
+ /**
+ * Get the target language for the content being parsed. This is
usually the
+ * language that the content is in.
+ */
+ function getTargetLanguage() {
$target = $this->mOptions->getTargetLanguage();
if ( $target !== null ) {
return $target;
@@ -707,6 +719,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
*
@@ -1225,7 +1249,8 @@
$text = $this->maybeMakeExternalImage( $url );
if ( $text === false ) {
# Not an image, make a link
- $text = Linker::makeExternalLink( $url,
$this->getFunctionLang()->markNoConversion($url), true, 'free',
+ $text = Linker::makeExternalLink( $url,
+
$this->getConverterLanguage()->markNoConversion($url), true, 'free',
$this->getExternalLinkAttribs( $url ) );
# Register it in the output object...
# Replace unnecessary URL escape codes with their
equivalent characters
@@ -1489,7 +1514,7 @@
# No link text, e.g. [http://domain.tld/some.link]
if ( $text == '' ) {
# Autonumber
- $langObj = $this->getFunctionLang();
+ $langObj = $this->getTargetLanguage();
$text = '[' . $langObj->formatNum(
++$this->mAutonumber ) . ']';
$linktype = 'autonumber';
} else {
@@ -1498,7 +1523,7 @@
list( $dtrail, $trail ) = Linker::splitTrail(
$trail );
}
- $text = $this->getFunctionLang()->markNoConversion(
$text );
+ $text =
$this->getConverterLanguage()->markNoConversion( $text );
$url = Sanitizer::cleanUrl( $url );
@@ -1678,7 +1703,7 @@
$line = $a->current(); # Workaround for broken
ArrayIterator::next() that returns "void"
$s = substr( $s, 1 );
- $useLinkPrefixExtension =
$this->getFunctionLang()->linkPrefixExtension();
+ $useLinkPrefixExtension =
$this->getTargetLanguage()->linkPrefixExtension();
$e2 = null;
if ( $useLinkPrefixExtension ) {
# Match the end of a line for a word that's not
followed by whitespace,
@@ -1704,8 +1729,9 @@
$prefix = '';
}
- if ( $this->getFunctionLang()->hasVariants() ) {
- $selflink =
$this->getFunctionLang()->autoConvertToAllVariants(
$this->mTitle->getPrefixedText() );
+ if ( $this->getConverterLanguage()->hasVariants() ) {
+ $selflink =
$this->getConverterLanguage()->autoConvertToAllVariants(
+ $this->mTitle->getPrefixedText() );
} else {
$selflink = array( $this->mTitle->getPrefixedText() );
}
@@ -1923,7 +1949,7 @@
}
$sortkey =
Sanitizer::decodeCharReferences( $sortkey );
$sortkey = str_replace( "\n", '',
$sortkey );
- $sortkey =
$this->getFunctionLang()->convertCategoryKey( $sortkey );
+ $sortkey =
$this->getConverterLanguage()->convertCategoryKey( $sortkey );
$this->mOutput->addCategory(
$nt->getDBkey(), $sortkey );
/**
@@ -3022,7 +3048,7 @@
* @private
*/
function braceSubstitution( $piece, $frame ) {
- global $wgNonincludableNamespaces;
+ global $wgNonincludableNamespaces, $wgContLang;
wfProfileIn( __METHOD__ );
wfProfileIn( __METHOD__.'-setup' );
@@ -3125,7 +3151,7 @@
$function =
$this->mFunctionSynonyms[1][$function];
} else {
# Case insensitive functions
- $function =
$this->getFunctionLang()->lc( $function );
+ $function = $wgContLang->lc( $function
);
if ( isset(
$this->mFunctionSynonyms[0][$function] ) ) {
$function =
$this->mFunctionSynonyms[0][$function];
} else {
@@ -3201,8 +3227,8 @@
if ( $title ) {
$titleText = $title->getPrefixedText();
# Check for language variants if the template
is not found
- if ( $this->getFunctionLang()->hasVariants() &&
$title->getArticleID() == 0 ) {
-
$this->getFunctionLang()->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();
@@ -4033,7 +4059,7 @@
if ( $dot ) {
$numbering .= '.';
}
- $numbering .=
$this->getFunctionLang()->formatNum( $sublevelCount[$i] );
+ $numbering .=
$this->getTargetLanguage()->formatNum( $sublevelCount[$i] );
$dot = 1;
}
}
Modified: branches/wmf/1.19wmf1/includes/specials/SpecialRecentchanges.php
===================================================================
--- branches/wmf/1.19wmf1/includes/specials/SpecialRecentchanges.php
2012-03-06 01:24:10 UTC (rev 113118)
+++ branches/wmf/1.19wmf1/includes/specials/SpecialRecentchanges.php
2012-03-06 02:09:48 UTC (rev 113119)
@@ -633,10 +633,13 @@
function setTopText( FormOptions $opts ) {
global $wgContLang;
$this->getOutput()->addWikiText(
- Html::rawElement( 'p',
- array( 'lang' => $wgContLang->getCode(), 'dir' =>
$wgContLang->getDir() ),
- "\n" . wfMsgForContentNoTrans( 'recentchangestext' ) .
"\n"
- ), false );
+ Html::rawElement( 'p',
+ array( 'lang' => $wgContLang->getCode(), 'dir'
=> $wgContLang->getDir() ),
+ "\n" . wfMsgForContentNoTrans(
'recentchangestext' ) . "\n"
+ ),
+ /* $lineStart */ false,
+ /* $interface */ false
+ );
}
/**
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs