From: C. Scott Ananian Date: Fri, 8 Jun 2018 15:45:07 +0000 (-0400) Subject: Remove unnecessary Parser::getConverterLanguage() indirection X-Git-Tag: 1.34.0-rc.0~5101 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=dbda7cdfb08f2928d91aebc68a1258b6a064a9b0;hp=4261fec2fa469e5173819ad9ad2f450859bda5ad;p=lhc%2Fweb%2Fwiklou.git Remove unnecessary Parser::getConverterLanguage() indirection The getConverterLanguage() method was added in March 2012 in commit 561424c266128a8c2c213cd803d4786313fc20cc as a workaround for a regression in mediawiki 1.19. It was an indirection which checked the global variable $wgBug34832TransitionalRollback to return a different converter language for Chinese wikis. When this temporary bugfix was reverted in January 2013 in commit a3fbdaaa2c4eb5ddc6bfbd62ae57a7804a307f12, the temporary global variable was removed, but not the getConverterLanguage() indirection. Since then, new code in the parser seems to have faithfully used getConverterLanguage() instead of getTargetLanguage(), even though they are identical and the need for getConverterLanguage() has long since passed. Strike a small blow for elegant minimalism by removing the completely unnecessary Parser::getConverterLanguage() indirection. Well, sort of: since this blight has been slowly growing inside Parser.php for so long, we need to deprecate getConverterLanguage() first just in case any external dependency has been infected. Next release we can finally excise the unnecessary method. Change-Id: I567c29c9c7699020955699b76cbe8578d02e2fe6 --- diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index cbbb48f520..16cea6db32 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -200,6 +200,8 @@ because of Phabricator reports. * Class CryptRand, everything in MWCryptRand except generateHex() and function MediaWikiServices::getCryptRand() are deprecated, use random_bytes() to generate cryptographically secure random byte sequences. +* Parser::getConverterLanguage() is deprecated. Use ::getTargetLanguage() + instead. === Other changes in 1.32 === * … diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 1ff8859cfb..42d5db70b8 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -449,7 +449,7 @@ class CoreParserFunctions { $parser->mOutput->setDisplayTitle( $text ); } if ( $old !== false && $old !== $text && !$arg ) { - $converter = $parser->getConverterLanguage()->getConverter(); + $converter = $parser->getTargetLanguage()->getConverter(); return '' . wfMessage( 'duplicate-displaytitle', // Message should be parsed, but these params should only be escaped. @@ -461,7 +461,7 @@ class CoreParserFunctions { return ''; } } else { - $converter = $parser->getConverterLanguage()->getConverter(); + $converter = $parser->getTargetLanguage()->getConverter(); $parser->getOutput()->addWarning( wfMessage( 'restricted-displaytitle', // Message should be parsed, but this param should only be escaped. @@ -982,7 +982,7 @@ class CoreParserFunctions { if ( $old === false || $old == $text || $arg ) { return ''; } else { - $converter = $parser->getConverterLanguage()->getConverter(); + $converter = $parser->getTargetLanguage()->getConverter(); return '' . wfMessage( 'duplicate-defaultsort', // Message should be parsed, but these params should only be escaped. diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 28e7450612..d3eff8a12c 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -460,11 +460,11 @@ class Parser { || isset( $this->mDoubleUnderscores['notitleconvert'] ) || $this->mOutput->getDisplayTitle() !== false ) ) { - $convruletitle = $this->getConverterLanguage()->getConvRuleTitle(); + $convruletitle = $this->getTargetLanguage()->getConvRuleTitle(); if ( $convruletitle ) { $this->mOutput->setTitleText( $convruletitle ); } else { - $titleText = $this->getConverterLanguage()->convertTitle( $title ); + $titleText = $this->getTargetLanguage()->convertTitle( $title ); $this->mOutput->setTitleText( $titleText ); } } @@ -897,6 +897,7 @@ class Parser { /** * Get the language object for language conversion + * @deprecated since 1.32, just use getTargetLanguage() * @return Language|null */ public function getConverterLanguage() { @@ -1380,7 +1381,7 @@ class Parser { # 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 ); + $text = $this->getTargetLanguage()->convert( $text ); } } @@ -1605,7 +1606,7 @@ class Parser { if ( $text === false ) { # Not an image, make a link $text = Linker::makeExternalLink( $url, - $this->getConverterLanguage()->markNoConversion( $url, true ), + $this->getTargetLanguage()->markNoConversion( $url, true ), true, 'free', $this->getExternalLinkAttribs( $url ), $this->mTitle ); # Register it in the output object... @@ -1894,7 +1895,7 @@ class Parser { list( $dtrail, $trail ) = Linker::splitTrail( $trail ); } - $text = $this->getConverterLanguage()->markNoConversion( $text ); + $text = $this->getTargetLanguage()->markNoConversion( $text ); $url = Sanitizer::cleanUrl( $url ); @@ -2360,7 +2361,7 @@ class Parser { } $sortkey = Sanitizer::decodeCharReferences( $sortkey ); $sortkey = str_replace( "\n", '', $sortkey ); - $sortkey = $this->getConverterLanguage()->convertCategoryKey( $sortkey ); + $sortkey = $this->getTargetLanguage()->convertCategoryKey( $sortkey ); $this->mOutput->addCategory( $nt->getDBkey(), $sortkey ); continue; @@ -3185,8 +3186,8 @@ class Parser { if ( $title ) { $titleText = $title->getPrefixedText(); # Check for language variants if the template is not found - if ( $this->getConverterLanguage()->hasVariants() && $title->getArticleID() == 0 ) { - $this->getConverterLanguage()->findVariantLink( $part1, $title, true ); + if ( $this->getTargetLanguage()->hasVariants() && $title->getArticleID() == 0 ) { + $this->getTargetLanguage()->findVariantLink( $part1, $title, true ); } # Do recursion depth check $limit = $this->mOptions->getMaxTemplateDepth();