diff options
Diffstat (limited to 'includes/parser/ParserOptions.php')
-rw-r--r-- | includes/parser/ParserOptions.php | 107 |
1 files changed, 52 insertions, 55 deletions
diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 009b18a1..e12f32d8 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -29,67 +29,62 @@ * @ingroup Parser */ class ParserOptions { - - /** - * Use DateFormatter to format dates - */ - var $mUseDynamicDates; - + /** * Interlanguage links are removed and returned in an array */ var $mInterwikiMagic; - + /** * Allow external images inline? */ var $mAllowExternalImages; - + /** * If not, any exception? */ var $mAllowExternalImagesFrom; - + /** * If not or it doesn't match, should we check an on-wiki whitelist? */ var $mEnableImageWhitelist; - + /** * Date format index */ var $mDateFormat = null; - + /** * Create "edit section" links? */ var $mEditSection = true; - + /** * Allow inclusion of special pages? */ var $mAllowSpecialInclusion; - + /** * Use tidy to cleanup output HTML? */ var $mTidy = false; - + /** * Which lang to call for PLURAL and GRAMMAR */ var $mInterfaceMessage = false; - + /** * Overrides $mInterfaceMessage with arbitrary language */ var $mTargetLanguage = null; - + /** * Maximum size of template expansions, in bytes */ var $mMaxIncludeSize; - + /** * Maximum number of nodes touched by PPFrame::expand() */ @@ -99,56 +94,56 @@ class ParserOptions { * Maximum number of nodes generated by Preprocessor::preprocessToObj() */ var $mMaxGeneratedPPNodeCount; - + /** * Maximum recursion depth in PPFrame::expand() */ var $mMaxPPExpandDepth; - + /** * Maximum recursion depth for templates within templates */ var $mMaxTemplateDepth; - + /** * Maximum number of calls per parse to expensive parser functions */ var $mExpensiveParserFunctionLimit; - + /** * Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS */ var $mRemoveComments = true; - + /** * Callback for template fetching. Used as first argument to call_user_func(). */ var $mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' ); - + /** * Enable limit report in an HTML comment on output */ var $mEnableLimitReport = false; - + /** * Timestamp used for {{CURRENTDAY}} etc. */ var $mTimestamp; - + /** * Target attribute for external links */ var $mExternalLinkTarget; - + /** - * Clean up signature texts? + * Clean up signature texts? * * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures * 2) Substitute all transclusions */ var $mCleanSignatures; - + /** * Transform wiki markup when saving the page? */ @@ -168,43 +163,43 @@ class ParserOptions { * Automatically number headings? */ var $mNumberHeadings; - + /** * User math preference (as integer). Not used (1.19) */ var $mMath; - + /** * Thumb size preferred by the user. */ var $mThumbSize; - + /** * Maximum article size of an article to be marked as "stub" */ private $mStubThreshold; - + /** * Language object of the User language. */ var $mUserLang; /** - * @var User + * @var User * Stored user object */ var $mUser; - + /** * Parsing the page for a "preview" operation? */ var $mIsPreview = false; - + /** * Parsing the page for a "preview" operation on a single section? */ var $mIsSectionPreview = false; - + /** * Parsing the printable version of the page? */ @@ -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 ) ) { @@ -415,14 +418,14 @@ class ParserOptions { return new ParserOptions( $context->getUser(), $context->getLanguage() ); } - /** - * Get user options + /** + * Get user options * * @param $user User object * @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. |