MediaWiki  master
ParserOptions Class Reference

Set options of the Parser. More...

Collaboration diagram for ParserOptions:

Public Member Functions

 __construct ($user=null, $lang=null)
 
 addExtraKey ($key)
 Extra key that should be present in the parser cache key. More...
 
 getEditSection ()
 Create "edit section" links? More...
 
 getRedirectTarget ()
 Get the previously-set redirect target. More...
 
 getTimestamp ()
 Timestamp used for {{CURRENTDAY}} etc. More...
 
 getUser ()
 Current user. More...
 
 isSafeToCache ()
 Test whether these options are safe to cache. More...
 
 matches (ParserOptions $other)
 Check if these options match that of another options set. More...
 
 optionsHash ($forOptions, $title=null)
 Generate a hash string with the values set on these ParserOptions for the keys given in the array. More...
 
 optionUsed ($optionName)
 Called when an option is accessed. More...
 
 registerWatcher ($callback)
 Registers a callback for tracking which ParserOptions which are used. More...
 
 setEditSection ($x)
 Create "edit section" links? More...
 
 setRedirectTarget ($title)
 Set the redirect target. More...
 
 setTimestamp ($x)
 Timestamp used for {{CURRENTDAY}} etc. More...
 
 setupFakeRevision ($title, $content, $user)
 Sets a hook to force that a page exists, and sets a current revision callback to return a revision with custom content when the current revision of the page is requested. More...
 

Static Public Member Functions

static allCacheVaryingOptions ()
 Return all option keys that vary the options hash. More...
 
static legacyOptions ()
 Returns the full array of options that would have been used by in 1.16. More...
 
static newCanonical (User $user=null, $lang=null)
 Creates a "canonical" ParserOptions object. More...
 
static newFromAnon ()
 Get a ParserOptions object for an anonymous user. More...
 
static newFromContext (IContextSource $context)
 Get a ParserOptions object from a IContextSource object. More...
 
static newFromUser ($user)
 Get a ParserOptions object from a given user. More...
 
static newFromUserAndLang (User $user, Language $lang)
 Get a ParserOptions object from a given user and language. More...
 

Private Member Functions

 initialiseFromUser ($user, $lang)
 Get user options. More...
 
 optionToString ($value)
 Convert an option to a string value. More...
 

Static Private Member Functions

static getCanonicalOverrides ()
 Get "canonical" non-default option values. More...
 
static getDefaults ()
 Get default option values. More...
 

Private Attributes

 $mExtraKey = ''
 Appended to the options hash. More...
 
string null $mTimestamp
 Timestamp used for {{CURRENTDAY}} etc. More...
 
User $mUser
 Stored user object. More...
 
callable null $onAccessCallback = null
 Function to be called when an option is accessed. More...
 
static callback[] static array
array 
$options
 Current values for all options that are relevant for caching. More...
 
Title null $redirectTarget = null
 If the page being parsed is a redirect, this should hold the redirect target. More...
 

Static Private Attributes

static array null $defaults = null
 Default values for all options that are relevant for caching. More...
 
static callback[] static array $inCacheKey
 Specify options that are included in the cache key. More...
 
static callback[] $lazyOptions
 Lazy-loaded options. More...
 

Option accessors

 getOption ($name)
 Fetch an option, generically. More...
 
 setOption ($name, $value)
 Set an option, generically. More...
 
 getInterwikiMagic ()
 Whether to extract interlanguage links. More...
 
 setInterwikiMagic ($x)
 Specify whether to extract interlanguage links. More...
 
 getAllowExternalImages ()
 Allow all external images inline? More...
 
 setAllowExternalImages ($x)
 Allow all external images inline? More...
 
 getAllowExternalImagesFrom ()
 External images to allow. More...
 
 setAllowExternalImagesFrom ($x)
 External images to allow. More...
 
 getEnableImageWhitelist ()
 Use the on-wiki external image whitelist? More...
 
 setEnableImageWhitelist ($x)
 Use the on-wiki external image whitelist? More...
 
 getNumberHeadings ()
 Automatically number headings? More...
 
 setNumberHeadings ($x)
 Automatically number headings? More...
 
 getAllowSpecialInclusion ()
 Allow inclusion of special pages? More...
 
 setAllowSpecialInclusion ($x)
 Allow inclusion of special pages? More...
 
 getTidy ()
 Use tidy to cleanup output HTML? More...
 
 setTidy ($x)
 Use tidy to cleanup output HTML? More...
 
 getInterfaceMessage ()
 Parsing an interface message? More...
 
 setInterfaceMessage ($x)
 Parsing an interface message? More...
 
 getTargetLanguage ()
 Target language for the parse. More...
 
 setTargetLanguage ($x)
 Target language for the parse. More...
 
 getMaxIncludeSize ()
 Maximum size of template expansions, in bytes. More...
 
 setMaxIncludeSize ($x)
 Maximum size of template expansions, in bytes. More...
 
 getMaxPPNodeCount ()
 Maximum number of nodes touched by PPFrame::expand() More...
 
 setMaxPPNodeCount ($x)
 Maximum number of nodes touched by PPFrame::expand() More...
 
 getMaxGeneratedPPNodeCount ()
 Maximum number of nodes generated by Preprocessor::preprocessToObj() More...
 
 setMaxGeneratedPPNodeCount ($x)
 Maximum number of nodes generated by Preprocessor::preprocessToObj() More...
 
 getMaxPPExpandDepth ()
 Maximum recursion depth in PPFrame::expand() More...
 
 getMaxTemplateDepth ()
 Maximum recursion depth for templates within templates. More...
 
 setMaxTemplateDepth ($x)
 Maximum recursion depth for templates within templates. More...
 
 getExpensiveParserFunctionLimit ()
 Maximum number of calls per parse to expensive parser functions. More...
 
 setExpensiveParserFunctionLimit ($x)
 Maximum number of calls per parse to expensive parser functions. More...
 
 getRemoveComments ()
 Remove HTML comments. More...
 
 setRemoveComments ($x)
 Remove HTML comments. More...
 
 getEnableLimitReport ()
 Enable limit report in an HTML comment on output. More...
 
 enableLimitReport ($x=true)
 Enable limit report in an HTML comment on output. More...
 
 getCleanSignatures ()
 Clean up signature texts? More...
 
 setCleanSignatures ($x)
 Clean up signature texts? More...
 
 getExternalLinkTarget ()
 Target attribute for external links. More...
 
 setExternalLinkTarget ($x)
 Target attribute for external links. More...
 
 getDisableContentConversion ()
 Whether content conversion should be disabled. More...
 
 disableContentConversion ($x=true)
 Whether content conversion should be disabled. More...
 
 getDisableTitleConversion ()
 Whether title conversion should be disabled. More...
 
 disableTitleConversion ($x=true)
 Whether title conversion should be disabled. More...
 
 getThumbSize ()
 Thumb size preferred by the user. More...
 
 setThumbSize ($x)
 Thumb size preferred by the user. More...
 
 getStubThreshold ()
 Thumb size preferred by the user. More...
 
 setStubThreshold ($x)
 Thumb size preferred by the user. More...
 
 getIsPreview ()
 Parsing the page for a "preview" operation? More...
 
 setIsPreview ($x)
 Parsing the page for a "preview" operation? More...
 
 getIsSectionPreview ()
 Parsing the page for a "preview" operation on a single section? More...
 
 setIsSectionPreview ($x)
 Parsing the page for a "preview" operation on a single section? More...
 
 getIsPrintable ()
 Parsing the printable version of the page? More...
 
 setIsPrintable ($x)
 Parsing the printable version of the page? More...
 
 getPreSaveTransform ()
 Transform wiki markup when saving the page? More...
 
 setPreSaveTransform ($x)
 Transform wiki markup when saving the page? More...
 
 getDateFormat ()
 Date format index. More...
 
 setDateFormat ($x)
 Date format index. More...
 
 getUserLangObj ()
 Get the user language used by the parser for this page and split the parser cache. More...
 
 getUserLang ()
 Same as getUserLangObj() but returns a string instead. More...
 
 setUserLang ($x)
 Set the user language used by the parser for this page and split the parser cache. More...
 
 getMagicISBNLinks ()
 Are magic ISBN links enabled? More...
 
 getMagicPMIDLinks ()
 Are magic PMID links enabled? More...
 
 getMagicRFCLinks ()
 Are magic RFC links enabled? More...
 
 getAllowUnsafeRawHtml ()
 If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of parsing this page. More...
 
 setAllowUnsafeRawHtml ($x)
 If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of parsing this page. More...
 
 getWrapOutputClass ()
 Class to use to wrap output from Parser::parse() More...
 
 setWrapOutputClass ($className)
 CSS class to use to wrap output from Parser::parse() More...
 
 getCurrentRevisionCallback ()
 Callback for current revision fetching; first argument to call_user_func(). More...
 
 setCurrentRevisionCallback ($x)
 Callback for current revision fetching; first argument to call_user_func(). More...
 
 getTemplateCallback ()
 Callback for template fetching; first argument to call_user_func(). More...
 
 setTemplateCallback ($x)
 Callback for template fetching; first argument to call_user_func(). More...
 
 getSpeculativeRevIdCallback ()
 Callback to generate a guess for {{REVISIONID}}. More...
 
 setSpeculativeRevIdCallback ($x)
 Callback to generate a guess for {{REVISIONID}}. More...
 
 setOptionLegacy ($name, $value)
 Legacy implementation. More...
 
static initDateFormat ($popt)
 Lazy initializer for dateFormat. More...
 

Detailed Description

Set options of the Parser.

How to add an option in core:

  1. Add it to one of the arrays in ParserOptions::setDefaults()
  2. If necessary, add an entry to ParserOptions::$inCacheKey
  3. Add a getter and setter in the section for that.

How to add an option in an extension:

  1. Use the 'ParserOptionsRegister' hook to register it.
  2. Where necessary, use $popt->getOption() and $popt->setOption() to access it.

Definition at line 40 of file ParserOptions.php.

Constructor & Destructor Documentation

ParserOptions::__construct (   $user = null,
  $lang = null 
)
Warning
For interaction with the parser cache, use WikiPage::makeParserOptions(), ContentHandler::makeParserOptions(), or ParserOptions::newCanonical() instead.
Parameters
User$user
Language$lang

Definition at line 936 of file ParserOptions.php.

References $lang, $user, $wgLang, global, initialiseFromUser(), StubObject\isRealObject(), and User.

Member Function Documentation

ParserOptions::addExtraKey (   $key)

Extra key that should be present in the parser cache key.

Warning
Consider registering your additional options with the ParserOptionsRegister hook instead of using this method.
Parameters
string$key

Definition at line 917 of file ParserOptions.php.

References $key.

static ParserOptions::allCacheVaryingOptions ( )
static

Return all option keys that vary the options hash.

Since
1.30
Returns
string[]

Definition at line 1233 of file ParserOptions.php.

Referenced by ParserCache\getETag(), ParserCache\getKey(), and ParserOptionsTest\testAllCacheVaryingOptions().

ParserOptions::disableContentConversion (   $x = true)

Whether content conversion should be disabled.

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 510 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::disableTitleConversion (   $x = true)

Whether title conversion should be disabled.

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 527 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::enableLimitReport (   $x = true)

Enable limit report in an HTML comment on output.

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 457 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::getAllowExternalImages ( )

Allow all external images inline?

Returns
bool

Definition at line 192 of file ParserOptions.php.

References getOption().

ParserOptions::getAllowExternalImagesFrom ( )

External images to allow.

When self::getAllowExternalImages() is false

Returns
string|string[] URLs to allow

Definition at line 212 of file ParserOptions.php.

References getOption().

ParserOptions::getAllowSpecialInclusion ( )

Allow inclusion of special pages?

Returns
bool

Definition at line 266 of file ParserOptions.php.

References getOption().

ParserOptions::getAllowUnsafeRawHtml ( )

If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of parsing this page.

This is meant to disable unsafe parser tags in cases where a malicious user may control the input to the parser.

Note
This is expected to be true for normal pages even if the wiki has $wgRawHtml disabled in general. The setting only signifies that raw html would be unsafe in the current context provided that raw html is allowed at all.
Since
1.29
Returns
bool

Definition at line 747 of file ParserOptions.php.

References getOption().

static ParserOptions::getCanonicalOverrides ( )
staticprivate

Get "canonical" non-default option values.

See also
self::newCanonical
Warning
If you change the override for an existing option, all existing parser cache entries will be invalid. To avoid bugs, you'll need to handle that somehow (e.g. with the RejectParserCacheValue hook) because MediaWiki won't do it for you.
Returns
array

Definition at line 1110 of file ParserOptions.php.

References global.

ParserOptions::getCleanSignatures ( )

Clean up signature texts?

See also
Parser::cleanSig
Returns
bool

Definition at line 466 of file ParserOptions.php.

References getOption().

ParserOptions::getCurrentRevisionCallback ( )

Callback for current revision fetching; first argument to call_user_func().

Since
1.24
Returns
callable

Definition at line 794 of file ParserOptions.php.

References getOption().

ParserOptions::getDateFormat ( )

Date format index.

Returns
string

Definition at line 637 of file ParserOptions.php.

References getOption().

static ParserOptions::getDefaults ( )
staticprivate

Get default option values.

Warning
If you change the default for an existing option (unless it's being overridden by self::getCanonicalOverrides()), all existing parser cache entries will be invalid. To avoid bugs, you'll need to handle that somehow (e.g. with the RejectParserCacheValue hook) because MediaWiki won't do it for you.
Returns
array

Definition at line 1037 of file ParserOptions.php.

References $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion, $wgInterwikiMagic, $wgMaxArticleSize, class, User\getDefaultOption(), global, and Hooks\run().

ParserOptions::getDisableContentConversion ( )

Whether content conversion should be disabled.

Returns
bool

Definition at line 501 of file ParserOptions.php.

References getOption().

ParserOptions::getDisableTitleConversion ( )

Whether title conversion should be disabled.

Returns
bool

Definition at line 518 of file ParserOptions.php.

References getOption().

Referenced by Parser\parse().

ParserOptions::getEditSection ( )

Create "edit section" links?

Deprecated:
since 1.31, use ParserOutput::getText() options instead.
Returns
bool

Definition at line 871 of file ParserOptions.php.

References wfDeprecated().

ParserOptions::getEnableImageWhitelist ( )

Use the on-wiki external image whitelist?

Returns
bool

Definition at line 232 of file ParserOptions.php.

References getOption().

ParserOptions::getEnableLimitReport ( )

Enable limit report in an HTML comment on output.

Returns
bool

Definition at line 448 of file ParserOptions.php.

References getOption().

ParserOptions::getExpensiveParserFunctionLimit ( )

Maximum number of calls per parse to expensive parser functions.

Since
1.20
Returns
int

Definition at line 411 of file ParserOptions.php.

References getOption().

ParserOptions::getExternalLinkTarget ( )

Target attribute for external links.

Returns
string

Definition at line 484 of file ParserOptions.php.

References getOption().

ParserOptions::getInterfaceMessage ( )

Parsing an interface message?

Returns
bool

Definition at line 300 of file ParserOptions.php.

References getOption().

ParserOptions::getInterwikiMagic ( )

Whether to extract interlanguage links.

When true, interlanguage links will be returned by ParserOutput::getLanguageLinks() instead of generating link HTML.

Returns
bool

Definition at line 175 of file ParserOptions.php.

References getOption().

ParserOptions::getIsPreview ( )

Parsing the page for a "preview" operation?

Returns
bool

Definition at line 569 of file ParserOptions.php.

References getOption().

ParserOptions::getIsPrintable ( )

Parsing the printable version of the page?

Returns
bool

Definition at line 603 of file ParserOptions.php.

References getOption().

ParserOptions::getIsSectionPreview ( )

Parsing the page for a "preview" operation on a single section?

Returns
bool

Definition at line 586 of file ParserOptions.php.

References getOption().

ParserOptions::getMagicISBNLinks ( )

Are magic ISBN links enabled?

Since
1.28
Returns
bool

Definition at line 712 of file ParserOptions.php.

References getOption().

ParserOptions::getMagicPMIDLinks ( )

Are magic PMID links enabled?

Since
1.28
Returns
bool

Definition at line 721 of file ParserOptions.php.

References getOption().

ParserOptions::getMagicRFCLinks ( )

Are magic RFC links enabled?

Since
1.28
Returns
bool

Definition at line 729 of file ParserOptions.php.

References getOption().

ParserOptions::getMaxGeneratedPPNodeCount ( )

Maximum number of nodes generated by Preprocessor::preprocessToObj()

Returns
int

Definition at line 368 of file ParserOptions.php.

References getOption().

ParserOptions::getMaxIncludeSize ( )

Maximum size of template expansions, in bytes.

Returns
int

Definition at line 334 of file ParserOptions.php.

References getOption().

ParserOptions::getMaxPPExpandDepth ( )

Maximum recursion depth in PPFrame::expand()

Returns
int

Definition at line 385 of file ParserOptions.php.

References getOption().

ParserOptions::getMaxPPNodeCount ( )

Maximum number of nodes touched by PPFrame::expand()

Returns
int

Definition at line 351 of file ParserOptions.php.

References getOption().

ParserOptions::getMaxTemplateDepth ( )

Maximum recursion depth for templates within templates.

Returns
int

Definition at line 393 of file ParserOptions.php.

References getOption().

ParserOptions::getNumberHeadings ( )

Automatically number headings?

Returns
bool

Definition at line 249 of file ParserOptions.php.

References getOption().

ParserOptions::getPreSaveTransform ( )

Transform wiki markup when saving the page?

Returns
bool

Definition at line 620 of file ParserOptions.php.

References getOption().

Referenced by Parser\preSaveTransform().

ParserOptions::getRedirectTarget ( )

Get the previously-set redirect target.

Since
1.24
Returns
Title|null

Definition at line 907 of file ParserOptions.php.

References $redirectTarget.

ParserOptions::getRemoveComments ( )

Remove HTML comments.

Warning
Only applies to preprocess operations
Returns
bool

Definition at line 430 of file ParserOptions.php.

References getOption().

ParserOptions::getSpeculativeRevIdCallback ( )

Callback to generate a guess for {{REVISIONID}}.

Since
1.28
Returns
callable|null

Definition at line 830 of file ParserOptions.php.

References getOption().

ParserOptions::getStubThreshold ( )

Thumb size preferred by the user.

Returns
int

Definition at line 552 of file ParserOptions.php.

References getOption().

Referenced by WikiPage\getParserOutput(), and WikiPage\shouldCheckParserCache().

ParserOptions::getTargetLanguage ( )

Target language for the parse.

Returns
Language|null

Definition at line 317 of file ParserOptions.php.

References getOption().

ParserOptions::getTemplateCallback ( )

Callback for template fetching; first argument to call_user_func().

Returns
callable

Definition at line 812 of file ParserOptions.php.

References getOption().

ParserOptions::getThumbSize ( )

Thumb size preferred by the user.

Returns
int

Definition at line 535 of file ParserOptions.php.

References getOption().

ParserOptions::getTidy ( )

Use tidy to cleanup output HTML?

Returns
bool

Definition at line 283 of file ParserOptions.php.

References getOption().

ParserOptions::getTimestamp ( )

Timestamp used for {{CURRENTDAY}} etc.

Returns
string

Definition at line 850 of file ParserOptions.php.

References $mTimestamp, and wfTimestampNow().

ParserOptions::getUser ( )

Current user.

Returns
User

Definition at line 925 of file ParserOptions.php.

References $mUser.

Referenced by optionsHash(), and Parser\testPst().

ParserOptions::getUserLang ( )

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 also
getUserLangObj()
Returns
string Language code
Since
1.17

Definition at line 690 of file ParserOptions.php.

References getUserLangObj().

ParserOptions::getUserLangObj ( )

Get the user language used by the parser for this page and split the parser cache.

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!
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.
When saving, this will return the default language instead of the user's. {{int: }} uses this which used to produce inconsistent link tables (T16404).
Returns
Language
Since
1.19

Definition at line 674 of file ParserOptions.php.

References getOption().

Referenced by getUserLang().

ParserOptions::getWrapOutputClass ( )

Class to use to wrap output from Parser::parse()

Since
1.30
Returns
string|bool

Definition at line 768 of file ParserOptions.php.

References getOption().

static ParserOptions::initDateFormat (   $popt)
staticprivate

Lazy initializer for dateFormat.

Definition at line 644 of file ParserOptions.php.

ParserOptions::initialiseFromUser (   $user,
  $lang 
)
private

Get user options.

Parameters
User$user
Language$lang

Definition at line 1125 of file ParserOptions.php.

References $lang, $user, and options().

Referenced by __construct().

ParserOptions::isSafeToCache ( )

Test whether these options are safe to cache.

Since
1.30
Returns
bool

Definition at line 1336 of file ParserOptions.php.

References $value, as, options(), and optionToString().

Referenced by WikiPage\getParserOutput().

static ParserOptions::legacyOptions ( )
static

Returns the full array of options that would have been used by in 1.16.

Used to get the old parser cache entries when available.

Deprecated:
since 1.30. You probably want self::allCacheVaryingOptions() instead.
Returns
string[]

Definition at line 1216 of file ParserOptions.php.

References wfDeprecated().

ParserOptions::matches ( ParserOptions  $other)

Check if these options match that of another options set.

This ignores report limit settings that only affect HTML comments

Parameters
ParserOptions$other
Returns
bool
Since
1.25

Definition at line 1144 of file ParserOptions.php.

References $name, as, options(), and optionToString().

static ParserOptions::newCanonical ( User  $user = null,
  $lang = null 
)
static
static ParserOptions::newFromAnon ( )
static

Get a ParserOptions object for an anonymous user.

Warning
For interaction with the parser cache, use WikiPage::makeParserOptions(), ContentHandler::makeParserOptions(), or ParserOptions::newCanonical() instead.
Since
1.27
Returns
ParserOptions

Definition at line 963 of file ParserOptions.php.

References $wgContLang, and global.

Referenced by MessageCache\getParserOptions(), and OutputPage\parserOptions().

static ParserOptions::newFromUser (   $user)
static
ParserOptions::optionsHash (   $forOptions,
  $title = null 
)

Generate a hash string with the values set on these ParserOptions for the keys given in the array.

This will be used as part of the hash key for the parser cache, so users sharing the options with vary for the same page share the same cached data safely.

Since
1.17
Parameters
string[]$forOptions
Title$titleUsed to get the content language of the page (since r97636)
Returns
string Page rendering hash

Definition at line 1275 of file ParserOptions.php.

References $mExtraKey, $options, $title, $wgContLang, $wgRenderHashAppend, as, getUser(), global, options(), optionToString(), and Hooks\run().

ParserOptions::optionToString (   $value)
private

Convert an option to a string value.

Parameters
mixed$value
Returns
string

Definition at line 1247 of file ParserOptions.php.

References $value.

Referenced by isSafeToCache(), matches(), and optionsHash().

ParserOptions::optionUsed (   $optionName)

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().

Parameters
string$optionNameName of the option

Definition at line 1203 of file ParserOptions.php.

Referenced by getOption().

ParserOptions::registerWatcher (   $callback)

Registers a callback for tracking which ParserOptions which are used.

This is a private API with the parser.

Parameters
callable$callback

Definition at line 1191 of file ParserOptions.php.

ParserOptions::setAllowExternalImages (   $x)

Allow all external images inline?

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 201 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setAllowExternalImagesFrom (   $x)

External images to allow.

When self::getAllowExternalImages() is false

Parameters
string|string[]|null$x New value (null is no change)
Returns
string|string[] Old value

Definition at line 224 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setAllowSpecialInclusion (   $x)

Allow inclusion of special pages?

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 275 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setAllowUnsafeRawHtml (   $x)

If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of parsing this page.

See also
self::getAllowUnsafeRawHtml()
Since
1.29
Parameters
bool | null$xValue to set or null to get current value
Returns
bool Current value for allowUnsafeRawHtml

Definition at line 759 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setCleanSignatures (   $x)

Clean up signature texts?

See also
Parser::cleanSig
Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 476 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setCurrentRevisionCallback (   $x)

Callback for current revision fetching; first argument to call_user_func().

Since
1.24
Parameters
callable | null$xNew value (null is no change)
Returns
callable Old value

Definition at line 804 of file ParserOptions.php.

References setOptionLegacy().

Referenced by setupFakeRevision().

ParserOptions::setDateFormat (   $x)

Date format index.

Parameters
string | null$xNew value (null is no change)
Returns
string Old value

Definition at line 653 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setEditSection (   $x)

Create "edit section" links?

Deprecated:
since 1.31, use ParserOutput::getText() options instead.
Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 882 of file ParserOptions.php.

References wfDeprecated().

ParserOptions::setEnableImageWhitelist (   $x)

Use the on-wiki external image whitelist?

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 241 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setExpensiveParserFunctionLimit (   $x)

Maximum number of calls per parse to expensive parser functions.

Since
1.20
Parameters
int | null$xNew value (null is no change)
Returns
int Old value

Definition at line 421 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setExternalLinkTarget (   $x)

Target attribute for external links.

Parameters
string | null$xNew value (null is no change)
Returns
string Old value

Definition at line 493 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setInterfaceMessage (   $x)

Parsing an interface message?

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 309 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setInterwikiMagic (   $x)

Specify whether to extract interlanguage links.

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 184 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setIsPreview (   $x)

Parsing the page for a "preview" operation?

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 578 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setIsPrintable (   $x)

Parsing the printable version of the page?

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 612 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setIsSectionPreview (   $x)

Parsing the page for a "preview" operation on a single section?

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 595 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setMaxGeneratedPPNodeCount (   $x)

Maximum number of nodes generated by Preprocessor::preprocessToObj()

Parameters
int | null$xNew value (null is no change)
Returns
int

Definition at line 377 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setMaxIncludeSize (   $x)

Maximum size of template expansions, in bytes.

Parameters
int | null$xNew value (null is no change)
Returns
int Old value

Definition at line 343 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setMaxPPNodeCount (   $x)

Maximum number of nodes touched by PPFrame::expand()

Parameters
int | null$xNew value (null is no change)
Returns
int Old value

Definition at line 360 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setMaxTemplateDepth (   $x)

Maximum recursion depth for templates within templates.

Parameters
int | null$xNew value (null is no change)
Returns
int Old value

Definition at line 402 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setNumberHeadings (   $x)

Automatically number headings?

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 258 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setOption (   $name,
  $value 
)

Set an option, generically.

Since
1.30
Parameters
string$nameOption name
mixed$valueNew value. Passing null will set null, unlike many of the existing accessors which ignore null for historical reasons.
Returns
mixed Old value

Definition at line 143 of file ParserOptions.php.

References $name, $value, and options().

Referenced by setTargetLanguage(), and setWrapOutputClass().

ParserOptions::setPreSaveTransform (   $x)

Transform wiki markup when saving the page?

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 629 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setRedirectTarget (   $title)

Set the redirect target.

Note that setting or changing this does not make the page a redirect or change its target, it merely records the information for reference during the parse.

Since
1.24
Parameters
Title | null$title

Definition at line 897 of file ParserOptions.php.

References $title.

ParserOptions::setRemoveComments (   $x)

Remove HTML comments.

Warning
Only applies to preprocess operations
Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 440 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setSpeculativeRevIdCallback (   $x)

Callback to generate a guess for {{REVISIONID}}.

Since
1.28
Parameters
callable | null$xNew value (null is no change)
Returns
callable|null Old value

Definition at line 840 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setStubThreshold (   $x)

Thumb size preferred by the user.

Parameters
int | null$xNew value (null is no change)
Returns
int Old value

Definition at line 561 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setTargetLanguage (   $x)

Target language for the parse.

Parameters
Language | null$xNew value
Returns
Language|null Old value

Definition at line 326 of file ParserOptions.php.

References setOption().

ParserOptions::setTemplateCallback (   $x)

Callback for template fetching; first argument to call_user_func().

Parameters
callable | null$xNew value (null is no change)
Returns
callable Old value

Definition at line 821 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setThumbSize (   $x)

Thumb size preferred by the user.

Parameters
int | null$xNew value (null is no change)
Returns
int Old value

Definition at line 544 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setTidy (   $x)

Use tidy to cleanup output HTML?

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value

Definition at line 292 of file ParserOptions.php.

References setOptionLegacy().

ParserOptions::setTimestamp (   $x)

Timestamp used for {{CURRENTDAY}} etc.

Parameters
string | null$xNew value (null is no change)
Returns
string Old value

Definition at line 862 of file ParserOptions.php.

References wfSetVar().

ParserOptions::setupFakeRevision (   $title,
  $content,
  $user 
)

Sets a hook to force that a page exists, and sets a current revision callback to return a revision with custom content when the current revision of the page is requested.

Since
1.25
Parameters
Title$title
Content$content
User$userThe user that the fake revision is attributed to
Returns
ScopedCallback to unset the hook

Definition at line 1360 of file ParserOptions.php.

References $key, $parser, $title, $user, $wgHooks, global, key, setCurrentRevisionCallback(), LinkCache\singleton(), and use.

ParserOptions::setUserLang (   $x)

Set the user language used by the parser for this page and split the parser cache.

Parameters
string | Language$xNew value
Returns
Language Old value

Definition at line 699 of file ParserOptions.php.

References Language\factory(), and setOptionLegacy().

ParserOptions::setWrapOutputClass (   $className)

CSS class to use to wrap output from Parser::parse()

Since
1.30
Parameters
string$classNameClass name to use for wrapping. Passing false to indicate "no wrapping" was deprecated in MediaWiki 1.31.
Returns
string|bool Current value

Definition at line 779 of file ParserOptions.php.

References setOption(), and wfDeprecated().

Member Data Documentation

array null ParserOptions::$defaults = null
staticprivate

Default values for all options that are relevant for caching.

See also
self::getDefaults()

Definition at line 47 of file ParserOptions.php.

callback [] static array ParserOptions::$inCacheKey
staticprivate
Initial value:
= [
'dateformat' => true

Specify options that are included in the cache key.

Definition at line 61 of file ParserOptions.php.

callback [] ParserOptions::$lazyOptions
staticprivate
Initial value:
= [
'dateformat' => [ __CLASS__, 'initDateFormat' ]

Lazy-loaded options.

Definition at line 53 of file ParserOptions.php.

ParserOptions::$mExtraKey = ''
private

Appended to the options hash.

Definition at line 108 of file ParserOptions.php.

Referenced by optionsHash().

string null ParserOptions::$mTimestamp
private

Timestamp used for {{CURRENTDAY}} etc.

Note
Caching based on parse time is handled externally

Definition at line 81 of file ParserOptions.php.

Referenced by getTimestamp().

User ParserOptions::$mUser
private

Stored user object.

Todo:
Track this for caching somehow without fragmenting the cache insanely

Definition at line 88 of file ParserOptions.php.

Referenced by getUser().

callable null ParserOptions::$onAccessCallback = null
private

Function to be called when an option is accessed.

Note
Used for collecting used options, does not affect caching

Definition at line 95 of file ParserOptions.php.

callback [] static array array ParserOptions::$options
private
Initial value:
=> true,
'thumbsize' => true,
'stubthreshold' => true,
'printable' => true,
'userlang' => true,
]

Current values for all options that are relevant for caching.

Definition at line 63 of file ParserOptions.php.

Referenced by optionsHash().

Title null ParserOptions::$redirectTarget = null
private

If the page being parsed is a redirect, this should hold the redirect target.

Todo:
Track this for caching somehow

Definition at line 103 of file ParserOptions.php.

Referenced by getRedirectTarget().


The documentation for this class was generated from the following file: