Merge "Refactor diffs"
[lhc/web/wiklou.git] / includes / parser / ParserOptions.php
index 064182e..e12f32d 100644 (file)
  */
 class ParserOptions {
 
-       /**
-        * Use DateFormatter to format dates
-        */
-       var $mUseDynamicDates;
-
        /**
         * Interlanguage links are removed and returned in an array
         */
@@ -220,7 +215,6 @@ class ParserOptions {
         */
        protected $onAccessCallback = null;
 
-       function getUseDynamicDates()               { return $this->mUseDynamicDates; }
        function getInterwikiMagic()                { return $this->mInterwikiMagic; }
        function getAllowExternalImages()           { return $this->mAllowExternalImages; }
        function getAllowExternalImagesFrom()       { return $this->mAllowExternalImagesFrom; }
@@ -246,6 +240,7 @@ class ParserOptions {
        function getExternalLinkTarget()            { return $this->mExternalLinkTarget; }
        function getDisableContentConversion()      { return $this->mDisableContentConversion; }
        function getDisableTitleConversion()        { return $this->mDisableTitleConversion; }
+       /** @deprecated since 1.22 use User::getOption('math') instead */
        function getMath()                          { $this->optionUsed( 'math' );
                                                                                                  return $this->mMath; }
        function getThumbSize()                     { $this->optionUsed( 'thumbsize' );
@@ -286,9 +281,17 @@ class ParserOptions {
        }
 
        /**
+        * Get the user language used by the parser for this page.
+        *
         * You shouldn't use this. Really. $parser->getFunctionLang() is all you need.
-        * Using this fragments the cache and is discouraged. Yes, {{int: }} uses this,
-        * producing inconsistent tables (Bug 14404).
+        *
+        * To avoid side-effects where the page will be rendered based on the language
+        * of the user who last saved, this function will triger a cache fragmentation.
+        * Usage of this method is discouraged for that reason.
+        *
+        * When saving, this will return the default language instead of the user's.
+        *
+        * {{int: }} uses this which used to produce inconsistent link tables (bug 14404).
         *
         * @return Language object
         * @since 1.19
@@ -308,7 +311,6 @@ class ParserOptions {
                return $this->getUserLangObj()->getCode();
        }
 
-       function setUseDynamicDates( $x )           { return wfSetVar( $this->mUseDynamicDates, $x ); }
        function setInterwikiMagic( $x )            { return wfSetVar( $this->mInterwikiMagic, $x ); }
        function setAllowExternalImages( $x )       { return wfSetVar( $this->mAllowExternalImages, $x ); }
        function setAllowExternalImagesFrom( $x )   { return wfSetVar( $this->mAllowExternalImagesFrom, $x ); }
@@ -319,7 +321,7 @@ class ParserOptions {
        function setAllowSpecialInclusion( $x )     { return wfSetVar( $this->mAllowSpecialInclusion, $x ); }
        function setTidy( $x )                      { return wfSetVar( $this->mTidy, $x ); }
 
-       /** @deprecated in 1.19; will be removed in 1.20 */
+       /** @deprecated in 1.19 */
        function setSkin( $x )                      { wfDeprecated( __METHOD__, '1.19' ); }
        function setInterfaceMessage( $x )          { return wfSetVar( $this->mInterfaceMessage, $x ); }
        function setTargetLanguage( $x )            { return wfSetVar( $this->mTargetLanguage, $x, true ); }
@@ -337,6 +339,7 @@ class ParserOptions {
        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 ); }
+       /** @deprecated since 1.22 */
        function setMath( $x )                      { return wfSetVar( $this->mMath, $x ); }
        function setUserLang( $x )                  {
                if ( is_string( $x ) ) {
@@ -422,7 +425,7 @@ class ParserOptions {
         * @param $lang Language object
         */
        private function initialiseFromUser( $user, $lang ) {
-               global $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages,
+               global $wgInterwikiMagic, $wgAllowExternalImages,
                        $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion,
                        $wgMaxArticleSize, $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth,
                        $wgCleanSignatures, $wgExternalLinkTarget, $wgExpensiveParserFunctionLimit,
@@ -430,7 +433,6 @@ class ParserOptions {
 
                wfProfileIn( __METHOD__ );
 
-               $this->mUseDynamicDates = $wgUseDynamicDates;
                $this->mInterwikiMagic = $wgInterwikiMagic;
                $this->mAllowExternalImages = $wgAllowExternalImages;
                $this->mAllowExternalImagesFrom = $wgAllowExternalImagesFrom;
@@ -481,12 +483,7 @@ class ParserOptions {
         * @return array
         */
        public static function legacyOptions() {
-               global $wgUseDynamicDates;
-               $legacyOpts = array( 'math', 'stubthreshold', 'numberheadings', 'userlang', 'thumbsize', 'editsection', 'printable' );
-               if ( $wgUseDynamicDates ) {
-                       $legacyOpts[] = 'dateformat';
-               }
-               return $legacyOpts;
+               return array( 'math', 'stubthreshold', 'numberheadings', 'userlang', 'thumbsize', 'editsection', 'printable' );
        }
 
        /**
@@ -518,14 +515,13 @@ class ParserOptions {
                        $confstr .= '*';
                }
 
-
                // Space assigned for the stubthreshold but unused
                // since it disables the parser cache, its value will always
                // be 0 when this function is called by parsercache.
                if ( in_array( 'stubthreshold', $forOptions ) ) {
                        $confstr .= '!' . $this->mStubThreshold;
                } else {
-                       $confstr .= '!*' ;
+                       $confstr .= '!*';
                }
 
                if ( in_array( 'dateformat', $forOptions ) ) {
@@ -552,7 +548,7 @@ class ParserOptions {
 
                // add in language specific options, if any
                // @todo FIXME: This is just a way of retrieving the url/user preferred variant
-               if( !is_null( $title ) ) {
+               if ( !is_null( $title ) ) {
                        $confstr .= $title->getPageLanguage()->getExtraHashOptions();
                } else {
                        global $wgContLang;
@@ -571,8 +567,9 @@ class ParserOptions {
                        $confstr .= '!printable=1';
                }
 
-               if ( $this->mExtraKey != '' )
+               if ( $this->mExtraKey != '' ) {
                        $confstr .= $this->mExtraKey;
+               }
 
                // Give a chance for extensions to modify the hash, if they have
                // extra options or other effects on the parser cache.