MediaWiki  master
ParserOptions Class Reference

Set options of the Parser. More...

Public Member Functions

 __construct (UserIdentity $user, $lang=null)
 
 addExtraKey ( $key)
 Extra key that should be present in the parser cache key. More...
 
 disableContentConversion ( $x=true)
 Whether content conversion should be disabled. More...
 
 disableTitleConversion ( $x=true)
 Whether title conversion should be disabled. More...
 
 enableLimitReport ( $x=true)
 
 getAllowExternalImages ()
 Allow all external images inline? More...
 
 getAllowExternalImagesFrom ()
 External images to allow. More...
 
 getAllowSpecialInclusion ()
 Allow inclusion of special pages? 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...
 
 getCleanSignatures ()
 Clean up signature texts? More...
 
 getCurrentRevisionRecordCallback ()
 Callback for current revision fetching; first argument to call_user_func(). More...
 
 getDateFormat ()
 Date format index. More...
 
 getDisableContentConversion ()
 Whether content conversion should be disabled. More...
 
 getDisableTitleConversion ()
 Whether title conversion should be disabled. More...
 
 getEnableImageWhitelist ()
 Use the on-wiki external image whitelist? More...
 
 getEnableLimitReport ()
 
 getExpensiveParserFunctionLimit ()
 Maximum number of calls per parse to expensive parser functions. More...
 
 getExternalLinkTarget ()
 Target attribute for external links. More...
 
 getInterfaceMessage ()
 Parsing an interface message? More...
 
 getInterwikiMagic ()
 Whether to extract interlanguage links. More...
 
 getIsPreview ()
 Parsing the page for a "preview" operation? More...
 
 getIsPrintable ()
 Parsing the printable version of the page? More...
 
 getIsSectionPreview ()
 Parsing the page for a "preview" operation on a single section? More...
 
 getMagicISBNLinks ()
 Are magic ISBN links enabled? More...
 
 getMagicPMIDLinks ()
 Are magic PMID links enabled? More...
 
 getMagicRFCLinks ()
 Are magic RFC links enabled? More...
 
 getMaxIncludeSize ()
 Maximum size of template expansions, in bytes. More...
 
 getMaxPPExpandDepth ()
 Maximum recursion depth in PPFrame::expand() More...
 
 getMaxPPNodeCount ()
 Maximum number of nodes touched by PPFrame::expand() More...
 
 getMaxTemplateDepth ()
 Maximum recursion depth for templates within templates. More...
 
 getOption ( $name)
 Fetch an option and track that is was accessed. More...
 
 getPreSaveTransform ()
 Transform wiki markup when saving the page? More...
 
 getRedirectTarget ()
 Get the previously-set redirect target. More...
 
 getRemoveComments ()
 Remove HTML comments. More...
 
 getRenderReason ()
 Returns reason for rendering the content. More...
 
 getSpeculativePageId ()
 A guess for {{PAGEID}}, calculated using the callback provided via setSpeculativeRevPageCallback(). More...
 
 getSpeculativeRevId ()
 A guess for {{REVISIONID}}, calculated using the callback provided via setSpeculativeRevIdCallback(). More...
 
 getSuppressTOC ()
 Should the table of contents be suppressed? Used when parsing "code" pages (like JavaScript) as wikitext for backlink support and categories, but where we don't want other metadata generated (like the table of contents). More...
 
 getTargetLanguage ()
 Target language for the parse. More...
 
 getTemplateCallback ()
 Callback for template fetching; first argument to call_user_func(). More...
 
 getThumbSize ()
 Thumb size preferred by the user. More...
 
 getTimestamp ()
 Timestamp used for {{CURRENTDAY}} etc. More...
 
 getUseParsoid ()
 Parsoid-format HTML output, or legacy wikitext parser HTML? More...
 
 getUserIdentity ()
 Get the identity of the user for whom the parse is made. More...
 
 getUserLang ()
 Same as getUserLangObj() but returns a string instead. More...
 
 getUserLangObj ()
 Get the user language used by the parser for this page and split the parser cache. More...
 
 getWrapOutputClass ()
 Class to use to wrap output from Parser::parse() More...
 
 isSafeToCache (array $usedOptions=null)
 Test whether these options are safe to cache. More...
 
 matches (ParserOptions $other)
 Check if these options match that of another options set. More...
 
 matchesForCacheKey (ParserOptions $other)
 
 optionsHash ( $forOptions, $title=null)
 Generate a hash string with the values set on these ParserOptions for the keys given in the array. More...
 
 registerWatcher ( $callback)
 Registers a callback for tracking which ParserOptions which are used. More...
 
 setAllowExternalImages ( $x)
 Allow all external images inline? More...
 
 setAllowExternalImagesFrom ( $x)
 External images to allow. More...
 
 setAllowSpecialInclusion ( $x)
 Allow inclusion of special pages? 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...
 
 setCleanSignatures ( $x)
 Clean up signature texts? More...
 
 setCurrentRevisionRecordCallback ( $x)
 Callback for current revision fetching; first argument to call_user_func(). More...
 
 setDateFormat ( $x)
 Date format index. More...
 
 setEnableImageWhitelist ( $x)
 Use the on-wiki external image whitelist? More...
 
 setExpensiveParserFunctionLimit ( $x)
 Maximum number of calls per parse to expensive parser functions. More...
 
 setExternalLinkTarget ( $x)
 Target attribute for external links. More...
 
 setInterfaceMessage ( $x)
 Parsing an interface message? More...
 
 setInterwikiMagic ( $x)
 Specify whether to extract interlanguage links. More...
 
 setIsPreview ( $x)
 Parsing the page for a "preview" operation? More...
 
 setIsPrintable ( $x)
 Parsing the printable version of the page? More...
 
 setIsSectionPreview ( $x)
 Parsing the page for a "preview" operation on a single section? More...
 
 setMaxIncludeSize ( $x)
 Maximum size of template expansions, in bytes. More...
 
 setMaxPPNodeCount ( $x)
 Maximum number of nodes touched by PPFrame::expand() More...
 
 setMaxTemplateDepth ( $x)
 Maximum recursion depth for templates within templates. More...
 
 setOption ( $name, $value)
 Set an option, generically. More...
 
 setPreSaveTransform ( $x)
 Transform wiki markup when saving the page? More...
 
 setRedirectTarget ( $title)
 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. More...
 
 setRemoveComments ( $x)
 Remove HTML comments. More...
 
 setRenderReason (string $renderReason)
 Sets reason for rendering the content. More...
 
 setSpeculativePageIdCallback ( $x)
 Callback to generate a guess for {{PAGEID}}. More...
 
 setSpeculativeRevIdCallback ( $x)
 Callback to generate a guess for {{REVISIONID}}. More...
 
 setSuppressTOC ()
 Suppress generation of the table of contents. More...
 
 setTargetLanguage ( $x)
 Target language for the parse. More...
 
 setTemplateCallback ( $x)
 Callback for template fetching; first argument to call_user_func(). More...
 
 setThumbSize ( $x)
 Thumb size preferred by the user. 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...
 
 setUseParsoid ()
 Request Parsoid-format HTML output. More...
 
 setUserLang ( $x)
 Set the user language used by the parser for this page and split the parser cache. More...
 
 setWrapOutputClass ( $className)
 CSS class to use to wrap output from Parser::parse() More...
 

Static Public Member Functions

static allCacheVaryingOptions ()
 Return all option keys that vary the options hash. More...
 
static clearStaticCache ()
 Reset static caches. More...
 
static getLazyOptions ()
 Get lazy-loaded options. More...
 
static newCanonical ( $context, $userLang=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 (UserIdentity $user, Language $lang)
 Get a ParserOptions object from a given user and language. More...
 

Protected Member Functions

 setOptionLegacy ( $name, $value)
 Legacy implementation. 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 49 of file ParserOptions.php.

Constructor & Destructor Documentation

◆ __construct()

ParserOptions::__construct ( UserIdentity  $user,
  $lang = null 
)
Parameters
UserIdentity$user
Language | null$lang

Definition at line 1058 of file ParserOptions.php.

References $lang, and $wgLang.

Member Function Documentation

◆ addExtraKey()

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 1041 of file ParserOptions.php.

◆ allCacheVaryingOptions()

static ParserOptions::allCacheVaryingOptions ( )
static

Return all option keys that vary the options hash.

Since
1.30
Returns
string[]

Definition at line 1371 of file ParserOptions.php.

◆ clearStaticCache()

static ParserOptions::clearStaticCache ( )
static

Reset static caches.

Access: internal
For testing

Definition at line 1148 of file ParserOptions.php.

◆ disableContentConversion()

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 565 of file ParserOptions.php.

◆ disableTitleConversion()

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 582 of file ParserOptions.php.

◆ enableLimitReport()

ParserOptions::enableLimitReport (   $x = true)
Deprecated:
since 1.38.

This does nothing now, to control limit reporting please provide 'includeDebugInfo' option to ParserOutput::getText.

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 510 of file ParserOptions.php.

◆ getAllowExternalImages()

ParserOptions::getAllowExternalImages ( )

Allow all external images inline?

Returns
bool

Definition at line 279 of file ParserOptions.php.

◆ getAllowExternalImagesFrom()

ParserOptions::getAllowExternalImagesFrom ( )

External images to allow.

When self::getAllowExternalImages() is false

Returns
string|string[] URLs to allow

Definition at line 302 of file ParserOptions.php.

◆ getAllowSpecialInclusion()

ParserOptions::getAllowSpecialInclusion ( )

Allow inclusion of special pages?

Returns
bool

Definition at line 345 of file ParserOptions.php.

◆ getAllowUnsafeRawHtml()

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 835 of file ParserOptions.php.

◆ getCleanSignatures()

ParserOptions::getCleanSignatures ( )

Clean up signature texts?

See also
Parser::cleanSig
Returns
bool

Definition at line 519 of file ParserOptions.php.

◆ getCurrentRevisionRecordCallback()

ParserOptions::getCurrentRevisionRecordCallback ( )

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

Access: internal
Since
1.35
Returns
callable

Definition at line 883 of file ParserOptions.php.

◆ getDateFormat()

ParserOptions::getDateFormat ( )

Date format index.

Returns
string

Definition at line 696 of file ParserOptions.php.

◆ getDisableContentConversion()

ParserOptions::getDisableContentConversion ( )

Whether content conversion should be disabled.

Returns
bool

Definition at line 556 of file ParserOptions.php.

◆ getDisableTitleConversion()

ParserOptions::getDisableTitleConversion ( )

Whether title conversion should be disabled.

Returns
bool

Definition at line 573 of file ParserOptions.php.

Referenced by Parser\parse().

◆ getEnableImageWhitelist()

ParserOptions::getEnableImageWhitelist ( )

Use the on-wiki external image whitelist?

Returns
bool

Definition at line 325 of file ParserOptions.php.

◆ getEnableLimitReport()

ParserOptions::getEnableLimitReport ( )
Deprecated:
since 1.38.

This does nothing now, to control limit reporting please provide 'includeDebugInfo' option to ParserOutput::getText.

Enable limit report in an HTML comment on output

Returns
bool

Definition at line 498 of file ParserOptions.php.

◆ getExpensiveParserFunctionLimit()

ParserOptions::getExpensiveParserFunctionLimit ( )

Maximum number of calls per parse to expensive parser functions.

Since
1.20
Returns
int

Definition at line 458 of file ParserOptions.php.

◆ getExternalLinkTarget()

ParserOptions::getExternalLinkTarget ( )

Target attribute for external links.

Returns
string|false
Access: internal
Only set by installer (T317647)

Definition at line 538 of file ParserOptions.php.

◆ getInterfaceMessage()

ParserOptions::getInterfaceMessage ( )

Parsing an interface message?

Returns
bool

Definition at line 362 of file ParserOptions.php.

◆ getInterwikiMagic()

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 262 of file ParserOptions.php.

◆ getIsPreview()

ParserOptions::getIsPreview ( )

Parsing the page for a "preview" operation?

Returns
bool

Definition at line 607 of file ParserOptions.php.

◆ getIsPrintable()

ParserOptions::getIsPrintable ( )

Parsing the printable version of the page?

Returns
bool

Definition at line 641 of file ParserOptions.php.

◆ getIsSectionPreview()

ParserOptions::getIsSectionPreview ( )

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

Returns
bool

Definition at line 624 of file ParserOptions.php.

◆ getLazyOptions()

static ParserOptions::getLazyOptions ( )
static

Get lazy-loaded options.

This array should be initialised by the constructor. The return type hint is used as an assertion to ensure this has happened and to coerce the type for static analysis.

Access: internal
Public for testing only
Returns
array

Definition at line 196 of file ParserOptions.php.

◆ getMagicISBNLinks()

ParserOptions::getMagicISBNLinks ( )

Are magic ISBN links enabled?

Since
1.28
Returns
bool

Definition at line 774 of file ParserOptions.php.

◆ getMagicPMIDLinks()

ParserOptions::getMagicPMIDLinks ( )

Are magic PMID links enabled?

Since
1.28
Returns
bool

Definition at line 783 of file ParserOptions.php.

◆ getMagicRFCLinks()

ParserOptions::getMagicRFCLinks ( )

Are magic RFC links enabled?

Since
1.28
Returns
bool

Definition at line 792 of file ParserOptions.php.

◆ getMaxIncludeSize()

ParserOptions::getMaxIncludeSize ( )

Maximum size of template expansions, in bytes.

Returns
int

Definition at line 396 of file ParserOptions.php.

Referenced by Parser\Parsoid\ParsoidParser\makeLimitReport().

◆ getMaxPPExpandDepth()

ParserOptions::getMaxPPExpandDepth ( )

Maximum recursion depth in PPFrame::expand()

Returns
int

Definition at line 430 of file ParserOptions.php.

◆ getMaxPPNodeCount()

ParserOptions::getMaxPPNodeCount ( )

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

Returns
int

Definition at line 413 of file ParserOptions.php.

◆ getMaxTemplateDepth()

ParserOptions::getMaxTemplateDepth ( )

Maximum recursion depth for templates within templates.

Returns
int
Access: internal
Only used by Parser (T318826)

Definition at line 439 of file ParserOptions.php.

◆ getOption()

ParserOptions::getOption (   $name)

Fetch an option and track that is was accessed.

Since
1.30
Parameters
string$nameOption name
Returns
mixed

Definition at line 156 of file ParserOptions.php.

◆ getPreSaveTransform()

ParserOptions::getPreSaveTransform ( )

Transform wiki markup when saving the page?

Returns
bool

Definition at line 658 of file ParserOptions.php.

Referenced by Parser\preSaveTransform().

◆ getRedirectTarget()

ParserOptions::getRedirectTarget ( )

Get the previously-set redirect target.

Since
1.24
Returns
Title|null

Definition at line 1031 of file ParserOptions.php.

◆ getRemoveComments()

ParserOptions::getRemoveComments ( )

Remove HTML comments.

Warning
Only applies to preprocess operations
Returns
bool

Definition at line 477 of file ParserOptions.php.

◆ getRenderReason()

ParserOptions::getRenderReason ( )

Returns reason for rendering the content.

This human-readable, intended for logging and debugging only. Expected values include "edit", "view", "purge", "LinksUpdate", etc.

Returns
string

Definition at line 1543 of file ParserOptions.php.

◆ getSpeculativePageId()

ParserOptions::getSpeculativePageId ( )

A guess for {{PAGEID}}, calculated using the callback provided via setSpeculativeRevPageCallback().

For consistency, the value will be calculated upon the first call of this method, and re-used for subsequent calls.

If no callback was defined via setSpeculativePageIdCallback(), this method will return false.

Since
1.34
Returns
int|false

Definition at line 939 of file ParserOptions.php.

◆ getSpeculativeRevId()

ParserOptions::getSpeculativeRevId ( )

A guess for {{REVISIONID}}, calculated using the callback provided via setSpeculativeRevIdCallback().

For consistency, the value will be calculated upon the first call of this method, and re-used for subsequent calls.

If no callback was defined via setSpeculativeRevIdCallback(), this method will return false.

Since
1.32
Returns
int|false

Definition at line 925 of file ParserOptions.php.

◆ getSuppressTOC()

ParserOptions::getSuppressTOC ( )

Should the table of contents be suppressed? Used when parsing "code" pages (like JavaScript) as wikitext for backlink support and categories, but where we don't want other metadata generated (like the table of contents).

See also
T307691
Since
1.39
Returns
bool

Definition at line 805 of file ParserOptions.php.

◆ getTargetLanguage()

ParserOptions::getTargetLanguage ( )

Target language for the parse.

Returns
Language|null

Definition at line 379 of file ParserOptions.php.

◆ getTemplateCallback()

ParserOptions::getTemplateCallback ( )

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

Returns
callable

Definition at line 902 of file ParserOptions.php.

◆ getThumbSize()

ParserOptions::getThumbSize ( )

Thumb size preferred by the user.

Returns
int

Definition at line 590 of file ParserOptions.php.

◆ getTimestamp()

ParserOptions::getTimestamp ( )

Timestamp used for {{CURRENTDAY}} etc.

Returns
string TS_MW timestamp

Definition at line 997 of file ParserOptions.php.

References wfTimestampNow().

◆ getUseParsoid()

ParserOptions::getUseParsoid ( )

Parsoid-format HTML output, or legacy wikitext parser HTML?

See also
T300191
Stability: unstable
Since
1.41
Returns
bool

Definition at line 678 of file ParserOptions.php.

◆ getUserIdentity()

ParserOptions::getUserIdentity ( )

Get the identity of the user for whom the parse is made.

Since
1.36
Returns
UserIdentity

Definition at line 1050 of file ParserOptions.php.

◆ getUserLang()

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::getTargetLanguage() instead!
See also
getUserLangObj()
Returns
string Language code
Since
1.17

Definition at line 752 of file ParserOptions.php.

◆ 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::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 736 of file ParserOptions.php.

◆ getWrapOutputClass()

ParserOptions::getWrapOutputClass ( )

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

Since
1.30
Returns
string|false

Definition at line 856 of file ParserOptions.php.

◆ isSafeToCache()

ParserOptions::isSafeToCache ( array  $usedOptions = null)

Test whether these options are safe to cache.

Parameters
string[] | null$usedOptionsthe list of options actually used in the parse. Defaults to all options.
Returns
bool
Since
1.30

Definition at line 1473 of file ParserOptions.php.

Referenced by Parser\RevisionOutputCache\save().

◆ matches()

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 1280 of file ParserOptions.php.

◆ matchesForCacheKey()

ParserOptions::matchesForCacheKey ( ParserOptions  $other)
Parameters
ParserOptions$other
Returns
bool Whether the cache key relevant options match those of $other
Since
1.33

Definition at line 1325 of file ParserOptions.php.

◆ newCanonical()

static ParserOptions::newCanonical (   $context,
  $userLang = null 
)
static

Creates a "canonical" ParserOptions object.

For historical reasons, certain options have default values that are different from the canonical values used for caching.

Since
1.30
1.32 Added string and IContextSource as options for the first parameter
1.36 UserIdentity is also allowed
Deprecated:
since 1.38. Use ::newFromContext, ::newFromAnon or ::newFromUserAndLang instead. Canonical ParserOptions are now exactly the same as non-canonical.
Parameters
IContextSource | string | UserIdentity$context
  • If an IContextSource, the options are initialized based on the source's UserIdentity and Language.
  • If the string 'canonical', the options are initialized with an anonymous user and the content language.
  • If a UserIdentity, the options are initialized for that UserIdentity 'userlang' is taken from the $userLang parameter, defaulting to $wgLang if that is null.
Language | StubObject | null$userLang(see above)
Returns
ParserOptions

Definition at line 1129 of file ParserOptions.php.

Referenced by WikiPage\makeParserOptionsFromTitleAndModel().

◆ newFromAnon()

◆ newFromContext()

◆ newFromUser()

static ParserOptions::newFromUser (   $user)
static

Get a ParserOptions object from a given user.

Language will be taken from $wgLang.

Parameters
UserIdentity$user
Returns
ParserOptions

Definition at line 1084 of file ParserOptions.php.

Referenced by CompareParsers\checkOptions(), Parser\cleanSig(), Parser\getFlatSectionInfo(), MediaWiki\Revision\RevisionRenderer\getRenderedRevision(), and DumpRenderer\handleRevision().

◆ newFromUserAndLang()

static ParserOptions::newFromUserAndLang ( UserIdentity  $user,
Language  $lang 
)
static

Get a ParserOptions object from a given user and language.

Parameters
UserIdentity$user
Language$lang
Returns
ParserOptions

Definition at line 1095 of file ParserOptions.php.

References $lang.

Referenced by MediaWiki\EditPage\EditPage\getContentObject(), LocalFile\getDescriptionText(), MediaWiki\Storage\DerivedPageDataUpdater\prepareContent(), and MediaWiki\EditPage\EditPage\showDiff().

◆ optionsHash()

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 | null$titleUsed to get the content language of the page (since r97636)
Returns
string Page rendering hash

Definition at line 1408 of file ParserOptions.php.

References $lang, and $title.

Referenced by Parser\ParserObserver\notifyParse().

◆ registerWatcher()

ParserOptions::registerWatcher (   $callback)

Registers a callback for tracking which ParserOptions which are used.

Since
1.16
Parameters
callable | null$callback

Definition at line 1347 of file ParserOptions.php.

◆ setAllowExternalImages()

ParserOptions::setAllowExternalImages (   $x)

Allow all external images inline?

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value
Deprecated:
since 1.35; per-parser configuration of image handling via parser options is deprecated. Use site configuration.

Definition at line 290 of file ParserOptions.php.

References wfDeprecated().

◆ setAllowExternalImagesFrom()

ParserOptions::setAllowExternalImagesFrom (   $x)

External images to allow.

When self::getAllowExternalImages() is false

Parameters
string | string[] | null$xNew value (null is no change)
Returns
string|string[] Old value
Deprecated:
since 1.35; per-parser configuration of image handling via parser options is deprecated. Use site configuration.

Definition at line 316 of file ParserOptions.php.

References wfDeprecated().

◆ setAllowSpecialInclusion()

ParserOptions::setAllowSpecialInclusion (   $x)

Allow inclusion of special pages?

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

Definition at line 354 of file ParserOptions.php.

◆ setAllowUnsafeRawHtml()

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 847 of file ParserOptions.php.

◆ setCleanSignatures()

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 529 of file ParserOptions.php.

◆ setCurrentRevisionRecordCallback()

ParserOptions::setCurrentRevisionRecordCallback (   $x)

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

Access: internal
Since
1.35
Parameters
callable | null$xNew value
Returns
callable Old value

Definition at line 894 of file ParserOptions.php.

◆ setDateFormat()

ParserOptions::setDateFormat (   $x)

Date format index.

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

Definition at line 715 of file ParserOptions.php.

◆ setEnableImageWhitelist()

ParserOptions::setEnableImageWhitelist (   $x)

Use the on-wiki external image whitelist?

Parameters
bool | null$xNew value (null is no change)
Returns
bool Old value
Deprecated:
since 1.35; per-parser configuration of image handling via parser options is deprecated. Use site configuration.

Definition at line 336 of file ParserOptions.php.

References wfDeprecated().

◆ setExpensiveParserFunctionLimit()

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 468 of file ParserOptions.php.

◆ setExternalLinkTarget()

ParserOptions::setExternalLinkTarget (   $x)

Target attribute for external links.

Parameters
string | false | null$xNew value (null is no change)
Returns
string Old value
Access: internal
Only used by installer (T317647)

Definition at line 548 of file ParserOptions.php.

◆ setInterfaceMessage()

ParserOptions::setInterfaceMessage (   $x)

Parsing an interface message?

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

Definition at line 371 of file ParserOptions.php.

◆ setInterwikiMagic()

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 271 of file ParserOptions.php.

◆ setIsPreview()

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 616 of file ParserOptions.php.

◆ setIsPrintable()

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 650 of file ParserOptions.php.

◆ setIsSectionPreview()

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 633 of file ParserOptions.php.

◆ setMaxIncludeSize()

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 405 of file ParserOptions.php.

◆ setMaxPPNodeCount()

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 422 of file ParserOptions.php.

◆ setMaxTemplateDepth()

ParserOptions::setMaxTemplateDepth (   $x)

Maximum recursion depth for templates within templates.

Parameters
int | null$xNew value (null is no change)
Returns
int Old value
Access: internal
Only used by ParserTestRunner (T318826)

Definition at line 449 of file ParserOptions.php.

◆ setOption()

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 230 of file ParserOptions.php.

◆ setOptionLegacy()

ParserOptions::setOptionLegacy (   $name,
  $value 
)
protected

Legacy implementation.

Since
1.30 For implementing legacy setters only. Don't use this in new code.
Deprecated:
since 1.30
Parameters
string$nameOption name
mixed$valueNew value. Passing null does not set the value.
Returns
mixed Old value

Definition at line 247 of file ParserOptions.php.

References wfSetVar().

◆ setPreSaveTransform()

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 667 of file ParserOptions.php.

◆ setRedirectTarget()

ParserOptions::setRedirectTarget (   $title)

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 1021 of file ParserOptions.php.

References $title.

◆ setRemoveComments()

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 487 of file ParserOptions.php.

◆ setRenderReason()

ParserOptions::setRenderReason ( string  $renderReason)

Sets reason for rendering the content.

This human-readable, intended for logging and debugging only. Expected values include "edit", "view", "purge", "LinksUpdate", etc.

Parameters
string$renderReason

Definition at line 1552 of file ParserOptions.php.

Referenced by Article\getParserOptions(), and Article\getParserOutput().

◆ setSpeculativePageIdCallback()

ParserOptions::setSpeculativePageIdCallback (   $x)

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

Parameters
callable | null$xNew value
Returns
callable|null Old value
Since
1.34

Definition at line 988 of file ParserOptions.php.

◆ setSpeculativeRevIdCallback()

ParserOptions::setSpeculativeRevIdCallback (   $x)

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

Parameters
callable | null$xNew value
Returns
callable|null Old value
Since
1.28

Definition at line 977 of file ParserOptions.php.

◆ setSuppressTOC()

ParserOptions::setSuppressTOC ( )

Suppress generation of the table of contents.

Used when parsing "code" pages (like JavaScript) as wikitext for backlink support and categories, but where we don't want other metadata generated (like the table of contents).

See also
T307691
Since
1.39

Definition at line 817 of file ParserOptions.php.

◆ setTargetLanguage()

ParserOptions::setTargetLanguage (   $x)

Target language for the parse.

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

Definition at line 388 of file ParserOptions.php.

◆ setTemplateCallback()

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 911 of file ParserOptions.php.

◆ setThumbSize()

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 599 of file ParserOptions.php.

◆ setTimestamp()

ParserOptions::setTimestamp (   $x)

Timestamp used for {{CURRENTDAY}} etc.

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

Definition at line 1009 of file ParserOptions.php.

References wfSetVar().

◆ setupFakeRevision()

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
UserIdentity$userThe user that the fake revision is attributed to
Returns
ScopedCallback to unset the hook

Definition at line 1499 of file ParserOptions.php.

References $content, and $title.

◆ setUseParsoid()

ParserOptions::setUseParsoid ( )

Request Parsoid-format HTML output.

See also
T300191
Stability: unstable
Since
1.41

Definition at line 688 of file ParserOptions.php.

◆ setUserLang()

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 761 of file ParserOptions.php.

◆ setWrapOutputClass()

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|false Current value

Definition at line 867 of file ParserOptions.php.

References wfDeprecated().


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