From dae0538793dc12bd56ebfffda478060517f359f6 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 1 Mar 2006 01:57:53 +0000 Subject: [PATCH] Fixed inappropriate access of $wgTitle from LanguageConverter.php. --- includes/Parser.php | 14 ++++---------- languages/Language.php | 6 ++++++ languages/LanguageConverter.php | 31 ++++++++++++++++++++----------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 3cc201d6f6..b3f13aa3cd 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -73,7 +73,7 @@ define( 'EXT_IMAGE_REGEX', * performs brace substitution on MediaWiki messages * * Globals used: - * objects: $wgLang + * objects: $wgLang, $wgContLang * * NOT $wgArticle, $wgUser or $wgTitle. Keep them away! * @@ -236,17 +236,11 @@ class Parser $this->replaceLinkHolders( $text ); - # the position of the convert() call should not be changed. it + # the position of the parserConvert() call should not be changed. it # assumes that the links are all replaced and the only thing left # is the mark. - $text = $wgContLang->convert($text); - - # FIXME: Unexpected data flow - # Set the title text in mOutput to a converted version of the global - # title. The title is stored in $wgContLang from a previous call to - # OutputPage::setPageTitle(). If no call has been made, this will be - # blank, a condition which Parser callers are expected to ignore. - $this->mOutput->setTitleText($wgContLang->getParsedTitle()); + # Side-effects: this calls $this->mOutput->setTitleText() + $text = $wgContLang->parserConvert( $text, $this ); $text = $this->unstripNoWiki( $text, $this->mStripState ); diff --git a/languages/Language.php b/languages/Language.php index 96753f03b6..f152146965 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -271,6 +271,7 @@ class fakeConverter { var $mLang; function fakeConverter($langobj) {$this->mLang = $langobj;} function convert($t, $i) {return $t;} + function parserConvert($t, $p) {return $t;} function getVariants() { return array( $this->mLang->getCode() ); } function getPreferredVariant() {return $this->mLang->getCode(); } function findVariantLink(&$l, &$n) {} @@ -1034,6 +1035,11 @@ class Language { return $this->mConverter->convert($text, $isTitle); } + # Convert text from within Parser + function parserConvert( $text, &$parser ) { + return $this->mConverter->parserConvert( $text, $parser ); + } + /** * Perform output conversion on a string, and encode for safe HTML output. * @param string $text diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 1992d7ef2d..38cb3dcb4e 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -182,6 +182,26 @@ class LanguageConverter { return $ret; } + /** + * Convert text using a parser object for context + */ + function parserConvert( $text, &$parser ) { + global $wgDisableLangConversion; + /* don't do anything if this is the conversion table */ + if ( $parser->mTitle->getNamespace() == NS_MEDIAWIKI && + strpos($parser->mTitle->getText, "Conversiontable") !== false ) + { + return $text; + } + + if($wgDisableLangConversion) + return $text; + + $text = $this->convert( $text ); + $parser->mOutput->setTitleText( $this->mTitleDisplay ); + return $text; + } + /** * convert text to different variants of a language. the automatic * conversion is done in autoConvert(). here we parse the text @@ -198,17 +218,6 @@ class LanguageConverter { * @access public */ function convert( $text , $isTitle=false) { - global $wgDisableLangConversion; - global $wgTitle; - - /* don't do anything if this is the conversion table */ - if($wgTitle->getNamespace() == NS_MEDIAWIKI && - strpos($wgTitle->getText(), "Conversiontable")!==false) - return $text; - - if($wgDisableLangConversion) - return $text; - $mw =& MagicWord::get( MAG_NOTITLECONVERT ); if( $mw->matchAndRemove( $text ) ) $this->mDoTitleConvert = false; -- 2.20.1