From 9573209efc74fbbfbdddc1b329114ed0cb12d34b Mon Sep 17 00:00:00 2001 From: Liangent Date: Sun, 10 Jun 2012 23:35:15 +0800 Subject: [PATCH] (bug 37453) Move $wgDisable(Lang|Title)Conversion to ParserOptions This allows easier fix of bug 37453, and patch to fix it is included in this changeset. Change-Id: I9096534639394755d0a296dea7380e7b938befef --- includes/WikiPage.php | 4 ++++ includes/parser/Parser.php | 10 ++++------ includes/parser/ParserOptions.php | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/includes/WikiPage.php b/includes/WikiPage.php index ff2d5bbf17..bc8766def0 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -1661,6 +1661,10 @@ class WikiPage extends Page implements IDBAccessObject { $options = ParserOptions::newFromUserAndLang( new User, $wgContLang ); } + if ( $this->getTitle()->isConversionTable() ) { + $options->disableContentConversion(); + } + $options->enableLimitReport(); // show inclusion/loop reports $options->setTidy( true ); // fix bad HTML diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 4b6af7f381..2a24bee79a 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -341,7 +341,7 @@ class Parser { * to internalParse() which does all the real work. */ - global $wgUseTidy, $wgAlwaysUseTidy, $wgDisableLangConversion, $wgDisableTitleConversion; + global $wgUseTidy, $wgAlwaysUseTidy; $fname = __METHOD__.'-' . wfGetCaller(); wfProfileIn( __METHOD__ ); wfProfileIn( $fname ); @@ -394,9 +394,8 @@ class Parser { * c) It's a conversion table * d) it is an interface message (which is in the user language) */ - if ( !( $wgDisableLangConversion - || isset( $this->mDoubleUnderscores['nocontentconvert'] ) - || $this->mTitle->isConversionTable() ) ) + if ( !( $options->getDisableContentConversion() + || isset( $this->mDoubleUnderscores['nocontentconvert'] ) ) ) { # Run convert unconditionally in 1.18-compatible mode global $wgBug34832TransitionalRollback; @@ -415,8 +414,7 @@ class Parser { * {{DISPLAYTITLE:...}} is present. DISPLAYTITLE takes precedence over * automatic link conversion. */ - if ( !( $wgDisableLangConversion - || $wgDisableTitleConversion + if ( !( $options->getDisableTitleConversion() || isset( $this->mDoubleUnderscores['nocontentconvert'] ) || isset( $this->mDoubleUnderscores['notitleconvert'] ) || $this->mOutput->getDisplayTitle() !== false ) ) diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index ff9f7efa6c..009b18a13e 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -154,6 +154,16 @@ class ParserOptions { */ var $mPreSaveTransform = true; + /** + * Whether content conversion should be disabled + */ + var $mDisableContentConversion; + + /** + * Whether title conversion should be disabled + */ + var $mDisableTitleConversion; + /** * Automatically number headings? */ @@ -234,6 +244,8 @@ class ParserOptions { function getEnableLimitReport() { return $this->mEnableLimitReport; } function getCleanSignatures() { return $this->mCleanSignatures; } function getExternalLinkTarget() { return $this->mExternalLinkTarget; } + function getDisableContentConversion() { return $this->mDisableContentConversion; } + function getDisableTitleConversion() { return $this->mDisableTitleConversion; } function getMath() { $this->optionUsed( 'math' ); return $this->mMath; } function getThumbSize() { $this->optionUsed( 'thumbsize' ); @@ -323,6 +335,8 @@ class ParserOptions { function setTimestamp( $x ) { return wfSetVar( $this->mTimestamp, $x ); } function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures, $x ); } function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget, $x ); } + function disableContentConversion( $x = true ) { return wfSetVar( $this->mDisableContentConversion, $x ); } + function disableTitleConversion( $x = true ) { return wfSetVar( $this->mDisableTitleConversion, $x ); } function setMath( $x ) { return wfSetVar( $this->mMath, $x ); } function setUserLang( $x ) { if ( is_string( $x ) ) { @@ -412,7 +426,7 @@ class ParserOptions { $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion, $wgMaxArticleSize, $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, $wgCleanSignatures, $wgExternalLinkTarget, $wgExpensiveParserFunctionLimit, - $wgMaxGeneratedPPNodeCount; + $wgMaxGeneratedPPNodeCount, $wgDisableLangConversion, $wgDisableTitleConversion; wfProfileIn( __METHOD__ ); @@ -430,6 +444,8 @@ class ParserOptions { $this->mExpensiveParserFunctionLimit = $wgExpensiveParserFunctionLimit; $this->mCleanSignatures = $wgCleanSignatures; $this->mExternalLinkTarget = $wgExternalLinkTarget; + $this->mDisableContentConversion = $wgDisableLangConversion; + $this->mDisableTitleConversion = $wgDisableLangConversion || $wgDisableTitleConversion; $this->mUser = $user; $this->mNumberHeadings = $user->getOption( 'numberheadings' ); -- 2.20.1