(bug 37453) Move $wgDisable(Lang|Title)Conversion to ParserOptions
authorLiangent <liangent@gmail.com>
Sun, 10 Jun 2012 15:35:15 +0000 (23:35 +0800)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Sun, 16 Sep 2012 18:20:36 +0000 (20:20 +0200)
This allows easier fix of bug 37453, and patch to fix it is
included in this changeset.

Change-Id: I9096534639394755d0a296dea7380e7b938befef

includes/WikiPage.php
includes/parser/Parser.php
includes/parser/ParserOptions.php

index ff2d5bb..bc8766d 100644 (file)
@@ -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
 
index 4b6af7f..2a24bee 100644 (file)
@@ -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 ) )
index ff9f7ef..009b18a 100644 (file)
@@ -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' );