summaryrefslogtreecommitdiff
path: root/includes/parser/ParserOptions.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/parser/ParserOptions.php')
-rw-r--r--includes/parser/ParserOptions.php99
1 files changed, 57 insertions, 42 deletions
diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php
index 100656d1..1073aed8 100644
--- a/includes/parser/ParserOptions.php
+++ b/includes/parser/ParserOptions.php
@@ -34,145 +34,145 @@ class ParserOptions {
/**
* Interlanguage links are removed and returned in an array
*/
- public $mInterwikiMagic;
+ private $mInterwikiMagic;
/**
* Allow external images inline?
*/
- public $mAllowExternalImages;
+ private $mAllowExternalImages;
/**
* If not, any exception?
*/
- public $mAllowExternalImagesFrom;
+ private $mAllowExternalImagesFrom;
/**
* If not or it doesn't match, should we check an on-wiki whitelist?
*/
- public $mEnableImageWhitelist;
+ private $mEnableImageWhitelist;
/**
* Date format index
*/
- public $mDateFormat = null;
+ private $mDateFormat = null;
/**
* Create "edit section" links?
*/
- public $mEditSection = true;
+ private $mEditSection = true;
/**
* Allow inclusion of special pages?
*/
- public $mAllowSpecialInclusion;
+ private $mAllowSpecialInclusion;
/**
* Use tidy to cleanup output HTML?
*/
- public $mTidy = false;
+ private $mTidy = false;
/**
* Which lang to call for PLURAL and GRAMMAR
*/
- public $mInterfaceMessage = false;
+ private $mInterfaceMessage = false;
/**
* Overrides $mInterfaceMessage with arbitrary language
*/
- public $mTargetLanguage = null;
+ private $mTargetLanguage = null;
/**
* Maximum size of template expansions, in bytes
*/
- public $mMaxIncludeSize;
+ private $mMaxIncludeSize;
/**
* Maximum number of nodes touched by PPFrame::expand()
*/
- public $mMaxPPNodeCount;
+ private $mMaxPPNodeCount;
/**
* Maximum number of nodes generated by Preprocessor::preprocessToObj()
*/
- public $mMaxGeneratedPPNodeCount;
+ private $mMaxGeneratedPPNodeCount;
/**
* Maximum recursion depth in PPFrame::expand()
*/
- public $mMaxPPExpandDepth;
+ private $mMaxPPExpandDepth;
/**
* Maximum recursion depth for templates within templates
*/
- public $mMaxTemplateDepth;
+ private $mMaxTemplateDepth;
/**
* Maximum number of calls per parse to expensive parser functions
*/
- public $mExpensiveParserFunctionLimit;
+ private $mExpensiveParserFunctionLimit;
/**
* Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
*/
- public $mRemoveComments = true;
+ private $mRemoveComments = true;
/**
* Callback for current revision fetching. Used as first argument to call_user_func().
*/
- public $mCurrentRevisionCallback =
+ private $mCurrentRevisionCallback =
array( 'Parser', 'statelessFetchRevision' );
/**
* Callback for template fetching. Used as first argument to call_user_func().
*/
- public $mTemplateCallback =
+ private $mTemplateCallback =
array( 'Parser', 'statelessFetchTemplate' );
/**
* Enable limit report in an HTML comment on output
*/
- public $mEnableLimitReport = false;
+ private $mEnableLimitReport = false;
/**
* Timestamp used for {{CURRENTDAY}} etc.
*/
- public $mTimestamp;
+ private $mTimestamp;
/**
* Target attribute for external links
*/
- public $mExternalLinkTarget;
+ private $mExternalLinkTarget;
/**
* Clean up signature texts?
* @see Parser::cleanSig
*/
- public $mCleanSignatures;
+ private $mCleanSignatures;
/**
* Transform wiki markup when saving the page?
*/
- public $mPreSaveTransform = true;
+ private $mPreSaveTransform = true;
/**
* Whether content conversion should be disabled
*/
- public $mDisableContentConversion;
+ private $mDisableContentConversion;
/**
* Whether title conversion should be disabled
*/
- public $mDisableTitleConversion;
+ private $mDisableTitleConversion;
/**
* Automatically number headings?
*/
- public $mNumberHeadings;
+ private $mNumberHeadings;
/**
* Thumb size preferred by the user.
*/
- public $mThumbSize;
+ private $mThumbSize;
/**
* Maximum article size of an article to be marked as "stub"
@@ -182,38 +182,38 @@ class ParserOptions {
/**
* Language object of the User language.
*/
- public $mUserLang;
+ private $mUserLang;
/**
* @var User
* Stored user object
*/
- public $mUser;
+ private $mUser;
/**
* Parsing the page for a "preview" operation?
*/
- public $mIsPreview = false;
+ private $mIsPreview = false;
/**
* Parsing the page for a "preview" operation on a single section?
*/
- public $mIsSectionPreview = false;
+ private $mIsSectionPreview = false;
/**
* Parsing the printable version of the page?
*/
- public $mIsPrintable = false;
+ private $mIsPrintable = false;
/**
* Extra key that should be present in the caching key.
*/
- public $mExtraKey = '';
+ private $mExtraKey = '';
/**
* Function to be called when an option is accessed.
*/
- protected $onAccessCallback = null;
+ private $onAccessCallback = null;
/**
* If the page being parsed is a redirect, this should hold the redirect
@@ -372,16 +372,17 @@ class ParserOptions {
}
/**
- * Get the user language used by the parser for this page.
+ * Get the user language used by the parser for this page and split the parser cache.
*
- * You shouldn't use this. Really. $parser->getFunctionLang() is all you need.
+ * @warning: Calling this causes the parser cache to be fragmented by user language!
+ * To avoid cache fragmentation, output should not depend on the user language.
+ * Use Parser::getFunctionLang() or Parser::getTargetLanguage() instead!
*
- * 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.
+ * @note This function will trigger a cache fragmentation by recording the
+ * 'userlang' option, see optionUsed(). This is done to avoid cache pollution
+ * when the page is rendered based on the language of the user.
*
+ * @note 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
@@ -395,6 +396,12 @@ class ParserOptions {
/**
* Same as getUserLangObj() but returns a string instead.
*
+ * @warning: Calling this causes the parser cache to be fragmented by user language!
+ * To avoid cache fragmentation, output should not depend on the user language.
+ * Use Parser::getFunctionLang() or Parser::getTargetLanguage() instead!
+ *
+ * @see getUserLangObj()
+ *
* @return string Language code
* @since 1.17
*/
@@ -700,6 +707,10 @@ class ParserOptions {
/**
* Called when an option is accessed.
+ * Calls the watcher that was set using registerWatcher().
+ * Typically, the watcher callback is ParserOutput::registerOption().
+ * The information registered that way will be used by ParserCache::save().
+ *
* @param string $optionName Name of the option
*/
public function optionUsed( $optionName ) {
@@ -791,6 +802,10 @@ class ParserOptions {
$confstr .= $wgRenderHashAppend;
+ // @note: as of Feb 2015, core never sets the editsection flag, since it uses
+ // <mw:editsection> tags to inject editsections on the fly. However, extensions
+ // may be using it by calling ParserOption::optionUsed resp. ParserOutput::registerOption
+ // directly. At least Wikibase does at this point in time.
if ( !in_array( 'editsection', $forOptions ) ) {
$confstr .= '!*';
} elseif ( !$this->mEditSection ) {