MediaWiki 1.40.4
ParserOutput Class Reference

Inherits CacheTime, and ContentMetadataCollector.

Collaboration diagram for ParserOutput:

Public Member Functions

 __construct ( $text=null, $languageLinks=[], $categoryLinks=[], $unused=false, $titletext='')
 
 __get ( $name)
 
 __set ( $name, $value)
 
 __sleep ()
 
 __wakeup ()
 
 addCacheMessage (string $msg)
 Adds a comment notice about cache state to the text of the page.
 
 addCategory ( $c, $sort='')
 Add a category.
 
 addExternalLink ( $url)
 
 addExtraCSPDefaultSrc ( $src)
 Add an extra value to Content-Security-Policy default-src directive.
 
 addExtraCSPScriptSrc ( $src)
 Add an extra value to Content-Security-Policy script-src directive.
 
 addExtraCSPStyleSrc ( $src)
 Add an extra value to Content-Security-Policy style-src directive.
 
 addHeadItem ( $section, $tag=false)
 Add some text to the "<head>".
 
 addImage ( $name, $timestamp=null, $sha1=null)
 Register a file dependency for this output.
 
 addInterwikiLink ( $link)
 
 addJsConfigVars ( $keys, $value=null)
 Add one or more variables to be set in mw.config in JavaScript.
 
 addLanguageLink ( $t)
 
 addLink (LinkTarget $link, $id=null)
 Record a local or interwiki inline link for saving in future link tables.
 
 addModules ( $modules)
 
 addModuleStyles ( $modules)
 
 addOutputHook ( $hook, $data=false)
 
 addOutputPageMetadata (OutputPage $out)
 Accommodate very basic transcluding of a temporary OutputPage object into parser output.
 
 addTemplate ( $link, $page_id, $rev_id)
 Register a template dependency for this output.
 
 addTrackingCategory ( $msg, PageReference $page)
 Add a tracking category, getting the title from a system message, or print a debug message if the title is invalid.
 
 addWarning ( $s)
 
 addWarningMsg (string $msg,... $args)
 Add a warning to the output for this page.
 
 addWrapperDivClass ( $class)
 Add a CSS class to use for the wrapping div.
 
 appendExtensionData (string $key, $value, string $strategy=self::MW_MERGE_STRATEGY_UNION)
 Appends arbitrary data to this ParserObject.
 
 appendJsConfigVar (string $key, string $value, string $strategy=self::MW_MERGE_STRATEGY_UNION)
 Append a value to a variable to be set in mw.config in JavaScript.
 
 clearWrapperDivClass ()
 Clears the CSS class to use for the wrapping div, effectively disabling the wrapper div until addWrapperDivClass() is called.
 
 collectMetadata (ContentMetadataCollector $metadata)
 Adds the metadata collected in this ParserOutput to the supplied ContentMetadataCollector.
 
 finalizeAdaptiveCacheExpiry ()
 Call this when parsing is done to lower the TTL based on low parse times.
 
 getAllFlags ()
 
getCategories ()
 
 getCategoryLinks ()
 Return the names of the categories on this page.
 
 getCategoryNames ()
 Return the names of the categories on this page.
 
 getCategorySortKey (string $name)
 Return the sort key for a given category name, or null if the category is not present in this ParserOutput.
 
 getDisplayTitle ()
 Get the title to be used for display.
 
 getEnableOOUI ()
 
 getExtensionData ( $key)
 Gets extensions data previously attached to this ParserOutput using setExtensionData().
 
getExternalLinks ()
 
 getExtraCSPDefaultSrcs ()
 Get extra Content-Security-Policy 'default-src' directives.
 
 getExtraCSPScriptSrcs ()
 Get extra Content-Security-Policy 'script-src' directives.
 
 getExtraCSPStyleSrcs ()
 Get extra Content-Security-Policy 'style-src' directives.
 
getFileSearchOptions ()
 
 getFlag ( $flag)
 
 getHeadItems ()
 
 getHideNewSection ()
 
getImages ()
 
 getIndexPolicy ()
 
 getIndicators ()
 
 getInterwikiLinks ()
 
 getJsConfigVars (bool $showStrategyKeys=false)
 
 getLanguage ()
 Get the primary language code of the output.
 
getLanguageLinks ()
 
 getLimitReportData ()
 
 getLimitReportJSData ()
 
getLinks ()
 
getLinksSpecial ()
 
 getModules ()
 
 getModuleStyles ()
 
 getNewSection ()
 
 getNoGallery ()
 
 getOutputFlag (string $name)
 Provides a uniform interface to various boolean flags stored in the ParserOutput.
 
 getOutputHooks ()
 
 getPageProperties ()
 Return all the page properties set on this ParserOutput.
 
 getPageProperty (string $name)
 Look up a page property.
 
 getPreventClickjacking ()
 Get the prevent-clickjacking flag.
 
 getProperties ()
 
 getProperty ( $name)
 
 getRawText ()
 Get the cacheable text with <mw:editsection> markers still in it.
 
 getRevisionTimestampUsed ()
 
 getRevisionUsedSha1Base36 ()
 
 getSections ()
 
 getSpeculativePageIdUsed ()
 
 getSpeculativeRevIdUsed ()
 
getTemplateIds ()
 
getTemplates ()
 
 getText ( $options=[])
 Get the output HTML.
 
 getTimeSinceStart ( $clock)
 Returns the time since resetParseStartTime() was last called.
 
 getTimestamp ()
 
 getTitleText ()
 
 getTOCData ()
 
 getTOCHTML ()
 
 getWarnings ()
 
 getWrapperDivClass ()
 Returns the class (or classes) to be used with the wrapper div for this output.
 
 hasDynamicContent ()
 
 hasReducedExpiry ()
 Check whether the cache TTL was lowered from the site default.
 
 hasText ()
 Returns true if text was passed to the constructor, or set using setText().
 
 hasTOCHTML ()
 
 hideNewSection ( $value)
 
 mergeHtmlMetaDataFrom (ParserOutput $source)
 Merges HTML metadata such as head items, JS config vars, and HTTP cache control info from $source into this ParserOutput.
 
 mergeInternalMetaDataFrom (ParserOutput $source)
 Merges internal metadata such as flags, accessed options, and profiling info from $source into this ParserOutput.
 
 mergeTrackingMetaDataFrom (ParserOutput $source)
 Merges dependency tracking metadata such as backlinks, images used, and extension data from $source into this ParserOutput.
 
 preventClickjacking ( $flag)
 Get or set the prevent-clickjacking flag.
 
 resetParseStartTime ()
 Resets the parse start timestamps for future calls to getTimeSinceStart()
 
 setCategories (array $c)
 Overwrite the category map.
 
 setCategoryLinks ( $cl)
 
 setDisplayTitle ( $text)
 Override the title to be used for display.
 
 setEnableOOUI (bool $enable=false)
 Enables OOUI, if true, in any OutputPage instance this ParserOutput object is added to.
 
 setExtensionData ( $key, $value)
 Attaches arbitrary data to this ParserObject.
 
 setFlag ( $flag)
 Attach a flag to the output so that it can be checked later to handle special cases.
 
 setHideNewSection (bool $value)
 
 setIndexPolicy ( $policy)
 
 setIndicator ( $id, $content)
 
 setJsConfigVar (string $key, $value)
 Add a variable to be set in mw.config in JavaScript.
 
 setLanguage (Bcp47Code $lang)
 Set the primary language of the output.
 
 setLanguageLinks ( $ll)
 
 setLimitReportData ( $key, $value)
 Sets parser limit report data for a key.
 
 setNewSection ( $value)
 
 setNoGallery ( $value)
 
 setOutputFlag (string $name, bool $val=true)
 Provides a uniform interface to various boolean flags stored in the ParserOutput.
 
 setPageProperty (string $name, $value)
 Set a page property to be stored in the page_props database table.
 
 setPreventClickjacking (bool $flag)
 Set the prevent-clickjacking flag.
 
 setProperty ( $name, $value)
 Sets a page property to be stored in the page_props database table.
 
 setRevisionTimestampUsed ( $timestamp)
 
 setRevisionUsedSha1Base36 ( $hash)
 
 setSections (array $sectionArray)
 
 setSpeculativePageIdUsed ( $id)
 
 setSpeculativeRevIdUsed ( $id)
 
 setText ( $text)
 Set the text of the ParserOutput.
 
 setTimestamp ( $timestamp)
 
 setTitleText ( $t)
 
 setTOCData (TOCData $tocData)
 
 setTOCHTML ( $tochtml)
 
 unsetPageProperty (string $name)
 Remove a page property.
 
 unsetProperty ( $name)
 
 updateRuntimeAdaptiveExpiry ( $ttl)
 Lower the runtime adaptive TTL to at most this value.
 
- Public Member Functions inherited from CacheTime
 expired ( $touched)
 Return true if this cached output object predates the global or per-article cache invalidation timestamps, or if it comes from an incompatible older version.
 
 getCacheExpiry ()
 Returns the number of seconds after which this object should expire.
 
 getCacheRevisionId ()
 
 getCacheTime ()
 
 getUsedOptions ()
 Returns the options from its ParserOptions which have been taken into account to produce the output.
 
 isCacheable ()
 
 isDifferentRevision ( $id)
 Return true if this cached output object is for a different revision of the page.
 
 recordOption (string $option)
 Tags a parser option for use in the cache key for this parser output.
 
 recordOptions (array $options)
 Tags a list of parser option names for use in the cache key for this parser output.
 
 setCacheRevisionId ( $id)
 
 setCacheTime ( $t)
 setCacheTime() sets the timestamp expressing when the page has been rendered.
 
 updateCacheExpiry ( $seconds)
 Sets the number of seconds after which this object should expire.
 

Static Public Member Functions

static isLinkInternal ( $internal, $url)
 Checks, if a url is pointing to the own server.
 
static newFromJsonArray (JsonUnserializer $unserializer, array $json)
 Creates a new instance of the class and initialized it from the $json array.
 

Public Attributes

const MW_MERGE_STRATEGY_KEY = '_mw-strategy'
 
const MW_MERGE_STRATEGY_UNION = 'union'
 Merge strategy to use for ParserOutput accumulators: "union" means that values are strings, stored as a set, and exposed as a PHP associative array mapping from values to true.
 
const SUPPORTS_STATELESS_TRANSFORMS = 1
 Feature flags to indicate to extensions that MediaWiki core supports and uses getText() stateless transforms.
 
const SUPPORTS_UNWRAP_TRANSFORM = 1
 

Protected Member Functions

 initFromJson (JsonUnserializer $unserializer, array $jsonData)
 Initialize member fields from an array returned by jsonSerialize().
 
 toJsonArray ()
 Returns a JSON serializable structure representing this ParserOutput instance.
 

Additional Inherited Members

- Protected Attributes inherited from CacheTime
int null $mCacheExpiry = null
 Seconds after which the object should expire, use 0 for not cacheable.
 
int null $mCacheRevisionId = null
 Revision ID that was parsed.
 
string int $mCacheTime = ''
 TS_MW timestamp when this object was generated, or -1 for not cacheable.
 
true[] $mParseUsedOptions = []
 ParserOptions which have been taken into account to produce output, option names stored in array keys.
 

Detailed Description

Definition at line 45 of file ParserOutput.php.

Constructor & Destructor Documentation

◆ __construct()

ParserOutput::__construct ( $text = null,
$languageLinks = [],
$categoryLinks = [],
$unused = false,
$titletext = '' )
Parameters
string | null$textHTML. Use null to indicate that this ParserOutput contains only meta-data, and the HTML output is undetermined, as opposed to empty. Passing null here causes hasText() to return false. In 1.39 the default value changed from '' to null.
array$languageLinks
array$categoryLinks
bool$unused
string$titletext

Definition at line 336 of file ParserOutput.php.

Member Function Documentation

◆ __get()

ParserOutput::__get ( $name)

Reimplemented from CacheTime.

Definition at line 2807 of file ParserOutput.php.

References wfDeprecatedMsg().

◆ __set()

ParserOutput::__set ( $name,
$value )

Reimplemented from CacheTime.

Definition at line 2822 of file ParserOutput.php.

References wfDeprecatedMsg().

◆ __sleep()

ParserOutput::__sleep ( )

Definition at line 2195 of file ParserOutput.php.

◆ __wakeup()

ParserOutput::__wakeup ( )

Reimplemented from CacheTime.

Definition at line 2789 of file ParserOutput.php.

◆ addCacheMessage()

ParserOutput::addCacheMessage ( string $msg)

Adds a comment notice about cache state to the text of the page.

Parameters
string$msg
Access: internal
used by ParserCache

Definition at line 578 of file ParserOutput.php.

Referenced by MediaWiki\Parser\RevisionOutputCache\save(), and ParserCache\save().

◆ addCategory()

ParserOutput::addCategory ( $c,
$sort = '' )

Add a category.

Parameters
string$cThe category name
string$sortThe sort key

Definition at line 1008 of file ParserOutput.php.

◆ addExternalLink()

ParserOutput::addExternalLink ( $url)

Definition at line 1128 of file ParserOutput.php.

◆ addExtraCSPDefaultSrc()

ParserOutput::addExtraCSPDefaultSrc ( $src)

Add an extra value to Content-Security-Policy default-src directive.

Call this if you are including a resource (e.g. image) from a third party domain. This is used for all source types except style and script.

Since
1.35
Parameters
string$srcCSP source e.g. example.com

Definition at line 2144 of file ParserOutput.php.

◆ addExtraCSPScriptSrc()

ParserOutput::addExtraCSPScriptSrc ( $src)

Add an extra value to Content-Security-Policy script-src directive.

Call this if you are loading third-party Javascript

Since
1.35
Parameters
string$srcCSP source e.g. example.com

Definition at line 2166 of file ParserOutput.php.

◆ addExtraCSPStyleSrc()

ParserOutput::addExtraCSPStyleSrc ( $src)

Add an extra value to Content-Security-Policy style-src directive.

Since
1.35
Parameters
string$srcCSP source e.g. example.com

Definition at line 2154 of file ParserOutput.php.

◆ addHeadItem()

ParserOutput::addHeadItem ( $section,
$tag = false )

Add some text to the "<head>".

If $tag is set, the section with that tag will only be included once in a given page.

Parameters
string$section
string | false$tag

Definition at line 1227 of file ParserOutput.php.

◆ addImage()

ParserOutput::addImage ( $name,
$timestamp = null,
$sha1 = null )

Register a file dependency for this output.

Parameters
string$nameTitle dbKey
string | false | null$timestampMW timestamp of file creation (or false if non-existing)
string | false | null$sha1Base 36 SHA-1 of file (or false if non-existing)

Definition at line 1185 of file ParserOutput.php.

◆ addInterwikiLink()

ParserOutput::addInterwikiLink ( $link)
Parameters
LinkTarget$linkLinkTarget object, must be an interwiki link (used to require Title until 1.38).
Exceptions
MWExceptionIf given invalid input

Definition at line 1212 of file ParserOutput.php.

◆ addJsConfigVars()

ParserOutput::addJsConfigVars ( $keys,
$value = null )

Add one or more variables to be set in mw.config in JavaScript.

Parameters
string | array$keysKey or array of key/value pairs.
mixed | null$value[optional] Value of the configuration variable.
Since
1.23
Deprecated
since 1.38, use ::setJsConfigVar() or ::appendJsConfigVar() which ensures compatibility with asynchronous parsing.

Definition at line 1270 of file ParserOutput.php.

References $keys.

◆ addLanguageLink()

ParserOutput::addLanguageLink ( $t)

Definition at line 1041 of file ParserOutput.php.

◆ addLink()

ParserOutput::addLink ( LinkTarget $link,
$id = null )

Record a local or interwiki inline link for saving in future link tables.

Parameters
LinkTarget$link(used to require Title until 1.38)
int | null$idOptional known page_id so we can skip the lookup

Definition at line 1152 of file ParserOutput.php.

Referenced by WikitextContentHandler\fillParserOutput().

◆ addModules()

ParserOutput::addModules ( $modules)
See also
OutputPage::addModules
Parameters
string[]$modules

Definition at line 1239 of file ParserOutput.php.

References wfDeprecated().

◆ addModuleStyles()

ParserOutput::addModuleStyles ( $modules)
See also
OutputPage::addModuleStyles
Parameters
string[]$modules

Definition at line 1252 of file ParserOutput.php.

References wfDeprecated().

Referenced by JsonContentHandler\fillParserOutput(), and WikitextContentHandler\fillParserOutput().

◆ addOutputHook()

ParserOutput::addOutputHook ( $hook,
$data = false )
Parameters
callable$hook
mixed$data
Deprecated
since 1.38; should be done in the OutputPageParserOutput hook (T292321).

Definition at line 1076 of file ParserOutput.php.

◆ addOutputPageMetadata()

ParserOutput::addOutputPageMetadata ( OutputPage $out)

Accommodate very basic transcluding of a temporary OutputPage object into parser output.

This is a fragile method that cannot be relied upon in any meaningful way. It exists solely to support the wikitext feature of transcluding a SpecialPage, and only has to work for that use case to ensure relevant styles are loaded, and that essential config vars needed between SpecialPage and a JS feature are added.

This relies on there being no overlap between modules or config vars added by the SpecialPage and those added by parser extensions. If there is overlap, then arise and break one or both sides. This is expected and unsupported.

Access: internal
For use by Parser for basic special page transclusion
Parameters
OutputPage$out

Definition at line 1360 of file ParserOutput.php.

◆ addTemplate()

ParserOutput::addTemplate ( $link,
$page_id,
$rev_id )

Register a template dependency for this output.

Parameters
LinkTarget$link(used to require Title until 1.38)
int$page_id
int$rev_id

Definition at line 1199 of file ParserOutput.php.

◆ addTrackingCategory()

ParserOutput::addTrackingCategory ( $msg,
PageReference $page )

Add a tracking category, getting the title from a system message, or print a debug message if the title is invalid.

Any message used with this function should be registered so it will show up on Special:TrackingCategories. Core messages should be added to TrackingCategories::CORE_TRACKING_CATEGORIES, and extensions should add to "TrackingCategories" in their extension.json.

Parameters
string$msgMessage key
PageReference$pagethe page which is being tracked (used to require a Title until 1.38)
Returns
bool Whether the addition was successful
Since
1.25
Deprecated
since 1.38, use Parser::addTrackingCategory or TrackingCategories::addTrackingCategory() instead

Definition at line 1400 of file ParserOutput.php.

◆ addWarning()

ParserOutput::addWarning ( $s)
Deprecated
since 1.38; use ::addWarningMsg() instead

Definition at line 1048 of file ParserOutput.php.

◆ addWarningMsg()

ParserOutput::addWarningMsg ( string $msg,
$args )

Add a warning to the output for this page.

Parameters
string$msgThe localization message key for the warning
mixed...$args Optional arguments for the message
Since
1.38

Definition at line 1059 of file ParserOutput.php.

◆ addWrapperDivClass()

ParserOutput::addWrapperDivClass ( $class)

Add a CSS class to use for the wrapping div.

If no class is given, no wrapper is added.

Parameters
string$class

Definition at line 587 of file ParserOutput.php.

◆ appendExtensionData()

ParserOutput::appendExtensionData ( string $key,
$value,
string $strategy = self::MW_MERGE_STRATEGY_UNION )

Appends arbitrary data to this ParserObject.

This can be used to store some information in the ParserOutput object for later use during page output. The data will be cached along with the ParserOutput object, but unlike data set using setPageProperty(), it is not recorded in the database.

See setExtensionData() for more details on rationale and use.

In order to provide for out-of-order/asynchronous/incremental parsing, this method appends values to a set. See setExtensionData() for the flag-like version of this method.

Note
Only values which can be array keys are currently supported as values.
Parameters
string$keyThe key for accessing the data. Extensions should take care to avoid conflicts in naming keys. It is suggested to use the extension's name as a prefix.
int | string$valueThe value to append to the list.
string$strategyMerge strategy: only MW_MERGE_STRATEGY_UNION is currently supported and external callers should treat this parameter as
Access: internal
at this time and omit it.
Since
1.38

Definition at line 1850 of file ParserOutput.php.

◆ appendJsConfigVar()

ParserOutput::appendJsConfigVar ( string $key,
string $value,
string $strategy = self::MW_MERGE_STRATEGY_UNION )

Append a value to a variable to be set in mw.config in JavaScript.

In order to ensure the result is independent of the parse order, the value of this key will be an associative array, mapping all of the values set under that key to true. (The array is implicitly ordered in PHP, but you should treat it as unordered.) If you want a non-array type for the key, and can ensure that only a single value will be set, you should use ::setJsConfigVar() instead.

Parameters
string$keyKey to use under mw.config
string$valueValue to append to the configuration variable.
string$strategyMerge strategy: only MW_MERGE_STRATEGY_UNION is currently supported and external callers should treat this parameter as
Access: internal
at this time and omit it.
Since
1.38

Definition at line 1324 of file ParserOutput.php.

◆ clearWrapperDivClass()

ParserOutput::clearWrapperDivClass ( )

Clears the CSS class to use for the wrapping div, effectively disabling the wrapper div until addWrapperDivClass() is called.

Definition at line 595 of file ParserOutput.php.

Referenced by CssContentHandler\fillParserOutput(), JavaScriptContentHandler\fillParserOutput(), and TextContentHandler\fillParserOutput().

◆ collectMetadata()

ParserOutput::collectMetadata ( ContentMetadataCollector $metadata)

Adds the metadata collected in this ParserOutput to the supplied ContentMetadataCollector.

This is similar to ::mergeHtmlMetaDataFrom() but in the opposite direction, since ParserOutput is read/write while ContentMetadataCollector is write-only.

Parameters
ContentMetadataCollector$metadata
Since
1.38

Definition at line 2369 of file ParserOutput.php.

◆ finalizeAdaptiveCacheExpiry()

ParserOutput::finalizeAdaptiveCacheExpiry ( )

Call this when parsing is done to lower the TTL based on low parse times.

Since
1.28

Definition at line 2175 of file ParserOutput.php.

◆ getAllFlags()

ParserOutput::getAllFlags ( )
Returns
string[] List of flags signifying special cases
Access: internal

Definition at line 1510 of file ParserOutput.php.

◆ getCategories()

& ParserOutput::getCategories ( )
Deprecated
since 1.40; use ::getCategoryNames() and ::getCategorySortKey()instead. This function will be made
Access: internal
in a future release.

Definition at line 722 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata(), and MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\setParserOutput().

◆ getCategoryLinks()

ParserOutput::getCategoryLinks ( )

Return the names of the categories on this page.

Returns
array<string>
Deprecated
since 1.38, use ::getCategoryNames() instead.

Definition at line 698 of file ParserOutput.php.

References wfDeprecated().

◆ getCategoryNames()

ParserOutput::getCategoryNames ( )

Return the names of the categories on this page.

Unlike ::getCategories(), sort keys are not included in the return value.

Returns
array<string> The names of the categories
Since
1.38

Definition at line 710 of file ParserOutput.php.

Referenced by MediaWiki\Search\ParserOutputSearchDataExtractor\getCategories().

◆ getCategorySortKey()

ParserOutput::getCategorySortKey ( string $name)

Return the sort key for a given category name, or null if the category is not present in this ParserOutput.

Parameters
string$nameThe category name
Returns
?string The sort key for the category, or null if the category is not present in this ParserOutput
Since
1.40

Definition at line 734 of file ParserOutput.php.

◆ getDisplayTitle()

ParserOutput::getDisplayTitle ( )

Get the title to be used for display.

As per the contract of setDisplayTitle(), this is safe HTML, ready to be served to the client.

Returns
string|false HTML

Definition at line 1430 of file ParserOutput.php.

References $t.

◆ getEnableOOUI()

ParserOutput::getEnableOOUI ( )

Definition at line 899 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getExtensionData()

ParserOutput::getExtensionData ( $key)

Gets extensions data previously attached to this ParserOutput using setExtensionData().

Typically, such data would be set while parsing the page, e.g. by a parser function.

Since
1.21
Parameters
string$keyThe key to look up.
Returns
mixed|null The value previously set for the given key using setExtensionData() or null if no value was set for this key.

Definition at line 1882 of file ParserOutput.php.

◆ getExternalLinks()

◆ getExtraCSPDefaultSrcs()

ParserOutput::getExtraCSPDefaultSrcs ( )

Get extra Content-Security-Policy 'default-src' directives.

Since
1.35
Returns
string[]

Definition at line 908 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getExtraCSPScriptSrcs()

ParserOutput::getExtraCSPScriptSrcs ( )

Get extra Content-Security-Policy 'script-src' directives.

Since
1.35
Returns
string[]

Definition at line 917 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getExtraCSPStyleSrcs()

ParserOutput::getExtraCSPStyleSrcs ( )

Get extra Content-Security-Policy 'style-src' directives.

Since
1.35
Returns
string[]

Definition at line 926 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getFileSearchOptions()

& ParserOutput::getFileSearchOptions ( )

Definition at line 797 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getFlag()

ParserOutput::getFlag ( $flag)
Parameters
string$flag
Returns
bool Whether the given flag was set to signify a special case
Deprecated
since 1.38; use ::getOutputFlag()

Definition at line 1502 of file ParserOutput.php.

◆ getHeadItems()

ParserOutput::getHeadItems ( )

Definition at line 813 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getHideNewSection()

ParserOutput::getHideNewSection ( )

Definition at line 1101 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getImages()

& ParserOutput::getImages ( )

◆ getIndexPolicy()

ParserOutput::getIndexPolicy ( )

Definition at line 856 of file ParserOutput.php.

Referenced by Article\getRobotPolicy().

◆ getIndicators()

ParserOutput::getIndicators ( )
Returns
string[]
Since
1.25

Definition at line 745 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getInterwikiLinks()

ParserOutput::getInterwikiLinks ( )

◆ getJsConfigVars()

ParserOutput::getJsConfigVars ( bool $showStrategyKeys = false)
Parameters
bool$showStrategyKeysDefaults to false; if set to true will expose the internal MW_MERGE_STRATEGY_KEY in the result. This should only be used internally to allow safe merge of config vars.
Returns
array
Since
1.23

Definition at line 832 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputContent(), and OutputPage\addParserOutputMetadata().

◆ getLanguage()

ParserOutput::getLanguage ( )

Get the primary language code of the output.

This gives the primary language of the output, including any variant used, as a MediaWiki-internal language code. This can be converted to a standard IETF language tag complying with BCP 47 by passing it to the LanguageCode::bcp47() method.

Note that this may differ from the wiki's primary language (because page language can differ from primary language) and can differ from the page language as well (because the parser uses the user language when processing interface messages). It will also differ from the Parser's target language when language conversion has been performed; in that case it will be equal to Parser::getTargetLanguageConverter()->getPreferredVariant(); use LanguageFactory::getParentLanguage() on that code if you need the base language. (Note that ::getPreferredVariant() depends on the request URL and the User language as well.)

Finally, note that the actual HTML included in this ParserOutput may actually represent content in multiple languages. It is expected that the HTML will use internal lang attributes (with BCP-47 values) to switch from the primary language reported by this method.

Returns
?Bcp47Code The primary language for this output, as a MediaWiki-internal language code, or null if a language was not set.
Since
1.40

Definition at line 1468 of file ParserOutput.php.

◆ getLanguageLinks()

& ParserOutput::getLanguageLinks ( )

◆ getLimitReportData()

ParserOutput::getLimitReportData ( )

Definition at line 891 of file ParserOutput.php.

◆ getLimitReportJSData()

ParserOutput::getLimitReportJSData ( )

Definition at line 895 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getLinks()

◆ getLinksSpecial()

& ParserOutput::getLinksSpecial ( )
Returns
array Keys are DBKs for the links to special pages in the document
Since
1.35

Definition at line 781 of file ParserOutput.php.

◆ getModules()

ParserOutput::getModules ( )

◆ getModuleStyles()

ParserOutput::getModuleStyles ( )

◆ getNewSection()

ParserOutput::getNewSection ( )

Definition at line 1105 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getNoGallery()

ParserOutput::getNoGallery ( )

Definition at line 809 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getOutputFlag()

ParserOutput::getOutputFlag ( string $name)

Provides a uniform interface to various boolean flags stored in the ParserOutput.

Flags internal to MediaWiki core should have names which are constants in ParserOutputFlags. Extensions should only use ::getOutputFlag() to query flags defined in ParserOutputFlags in core; they should use getExtensionData() to define their own flags.

Parameters
string$nameA flag name
Returns
bool The flag value
Since
1.38

Definition at line 1732 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getOutputHooks()

ParserOutput::getOutputHooks ( )
Returns
array
Deprecated
since 1.38; should be done in the OutputPageParserOutput hook (T292321).

Definition at line 848 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getPageProperties()

ParserOutput::getPageProperties ( )

Return all the page properties set on this ParserOutput.

Returns
array<string,int|float|string|bool|null>
Since
1.38

Definition at line 1653 of file ParserOutput.php.

Referenced by MediaWiki\Deferred\LinksUpdate\PagePropsTable\setParserOutput().

◆ getPageProperty()

ParserOutput::getPageProperty ( string $name)

Look up a page property.

Parameters
string$nameThe page property name to look up.
Returns
int|float|string|bool|null The value previously set using setPageProperty(). Returns null if no value was set for the given property name.
Note
You would need to use ::getPageProperties() to test for an explicitly-set null value; but see the note in ::setPageProperty() about avoiding the use of non-string values.
Since
1.38

Definition at line 1635 of file ParserOutput.php.

◆ getPreventClickjacking()

ParserOutput::getPreventClickjacking ( )

Get the prevent-clickjacking flag.

Returns
bool Flag value
Since
1.38

Definition at line 2102 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getProperties()

ParserOutput::getProperties ( )
Returns
array
Deprecated
since 1.38, renamed to ::getPageProperties()

Definition at line 1553 of file ParserOutput.php.

References wfDeprecated().

◆ getProperty()

ParserOutput::getProperty ( $name)
Parameters
string$nameThe property name to look up.
Returns
mixed|bool The value previously set using setPageProperty(). False if null or no value was set for the given property name.
Note
You need to use getPageProperties() to check for boolean and null properties.
Deprecated
since 1.38, renamed to ::getPageProperty() and returns null if no value was set.

Definition at line 1535 of file ParserOutput.php.

References wfDeprecated().

◆ getRawText()

ParserOutput::getRawText ( )

Get the cacheable text with <mw:editsection> markers still in it.

The return value is suitable for writing back via setText() but is not valid for display to the user.

Returns
string
Since
1.27

Definition at line 367 of file ParserOutput.php.

References $mText.

Referenced by WikitextContentHandler\fillParserOutput().

◆ getRevisionTimestampUsed()

ParserOutput::getRevisionTimestampUsed ( )
Returns
string|null TS_MW timestamp or null if not used
Since
1.34

Definition at line 654 of file ParserOutput.php.

◆ getRevisionUsedSha1Base36()

ParserOutput::getRevisionUsedSha1Base36 ( )
Returns
string|null Lowercase SHA-1 base 36 hash, null if unused, or "" on inconsistency
Since
1.34

Definition at line 681 of file ParserOutput.php.

◆ getSections()

ParserOutput::getSections ( )
Access: internal
Returns
array

Definition at line 765 of file ParserOutput.php.

◆ getSpeculativePageIdUsed()

ParserOutput::getSpeculativePageIdUsed ( )
Returns
int|null
Since
1.34

Definition at line 638 of file ParserOutput.php.

◆ getSpeculativeRevIdUsed()

ParserOutput::getSpeculativeRevIdUsed ( )
Returns
int|null
Since
1.28

Definition at line 622 of file ParserOutput.php.

◆ getTemplateIds()

& ParserOutput::getTemplateIds ( )

Definition at line 789 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getTemplates()

◆ getText()

ParserOutput::getText ( $options = [])

Get the output HTML.

Parameters
array$options(since 1.31) Transformations to apply to the HTML
  • allowTOC: (bool) Show the TOC, assuming there were enough headings to generate one and __NOTOC__ wasn't used. Default is true, but might be statefully overridden.
  • injectTOC: (bool) Replace the TOC_PLACEHOLDER with TOC contents; otherwise the marker will be left in the article (and the skin will be responsible for replacing or removing it). Default is true.
  • enableSectionEditLinks: (bool) Include section edit links, assuming section edit link tokens are present in the HTML. Default is true, but might be statefully overridden.
  • userLang: (Language) Language object used for localizing UX messages, for example the heading of the table of contents. If omitted, will use the language of the main request context.
  • skin: (Skin) Skin object used for transforming section edit links.
  • unwrap: (bool) Return text without a wrapper div. Default is false, meaning a wrapper div will be added if getWrapperDivClass() returns a non-empty string.
  • wrapperDivClass: (string) Wrap the output in a div and apply the given CSS class to that div. This overrides the output of getWrapperDivClass(). Setting this to an empty string has the same effect as 'unwrap' => true.
  • deduplicateStyles: (bool) When true, which is the default, <style> tags with the data-mw-deduplicate attribute set are deduplicated by value of the attribute: all but the first will be replaced by <link rel="mw-deduplicated-inline-style" href="mw-data:..."/> tags, where the scheme-specific-part of the href is the (percent-encoded) value of the data-mw-deduplicate attribute.
  • absoluteURLs: (bool) use absolute URLs in all links. Default: false
  • includeDebugInfo: (bool) render PP limit report in HTML. Default: false
Returns
string HTML
-taint escaped

Definition at line 410 of file ParserOutput.php.

References getExtensionData(), Parser\replaceTableOfContentsMarker(), and wfUrlencode().

Referenced by OutputPage\addParserOutputText(), Status\getHTML(), and Message\parseText().

◆ getTimeSinceStart()

ParserOutput::getTimeSinceStart ( $clock)

Returns the time since resetParseStartTime() was last called.

Clocks available are:

  • wall: Wall clock time
  • cpu: CPU time (requires getrusage)
Since
1.22
Parameters
string$clock
Returns
float|null

Definition at line 1923 of file ParserOutput.php.

◆ getTimestamp()

ParserOutput::getTimestamp ( )
Returns
string|null TS_MW timestamp of the revision content

Definition at line 887 of file ParserOutput.php.

◆ getTitleText()

ParserOutput::getTitleText ( )

Definition at line 749 of file ParserOutput.php.

Referenced by Article\adjustDisplayTitle().

◆ getTOCData()

ParserOutput::getTOCData ( )
Returns
?TOCData the table of contents data, or null if it hasn't been set.

Definition at line 757 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ getTOCHTML()

ParserOutput::getTOCHTML ( )
Deprecated
since 1.40; use ::getTOCData() instead

Definition at line 869 of file ParserOutput.php.

References wfDeprecated().

◆ getWarnings()

ParserOutput::getWarnings ( )

Definition at line 852 of file ParserOutput.php.

◆ getWrapperDivClass()

ParserOutput::getWrapperDivClass ( )

Returns the class (or classes) to be used with the wrapper div for this output.

If there is no wrapper class given, no wrapper div should be added. The wrapper div is added automatically by getText().

Returns
string

Definition at line 606 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ hasDynamicContent()

ParserOutput::hasDynamicContent ( )
See also
ParserOutput::hasReducedExpiry
Returns
bool
Since
1.25
Deprecated
since 1.38: use ::hasReducedExpiry()

Definition at line 2081 of file ParserOutput.php.

◆ hasReducedExpiry()

ParserOutput::hasReducedExpiry ( )

Check whether the cache TTL was lowered from the site default.

When content is determined by more than hard state (e.g. page edits), such as template/file transclusions based on the current timestamp or extension tags that generate lists based on queries, this return true.

This method mainly exists to facilitate the logic in WikiPage::triggerOpportunisticLinksUpdate. As such, beware that reducing the TTL for reasons that do not relate to "dynamic content", may have the side-effect of incurring more RefreshLinksJob executions.

Access: internal
For use by Parser and WikiPage
Since
1.37
Returns
bool

Definition at line 2068 of file ParserOutput.php.

Referenced by WikiPage\triggerOpportunisticLinksUpdate().

◆ hasText()

ParserOutput::hasText ( )

Returns true if text was passed to the constructor, or set using setText().

Returns false if null was passed to the $text parameter of the constructor to indicate that this ParserOutput only contains meta-data, and the HTML output is undetermined.

Since
1.32
Returns
bool Whether this ParserOutput contains rendered text. If this returns false, the ParserOutput contains meta-data only.

Definition at line 355 of file ParserOutput.php.

Referenced by MediaWiki\Parser\RevisionOutputCache\save(), and ParserCache\save().

◆ hasTOCHTML()

ParserOutput::hasTOCHTML ( )
Returns
bool
Access: internal
Only for the temporary use of OutputPage::addParserOutputMetadata; will be removed with ::{get,set}TOCHTML().

Definition at line 880 of file ParserOutput.php.

Referenced by OutputPage\addParserOutputMetadata().

◆ hideNewSection()

ParserOutput::hideNewSection ( $value)
Parameters
bool$valueHide the new section link?
Deprecated
since 1.38 use ::setHideNewSection()

Definition at line 1096 of file ParserOutput.php.

◆ initFromJson()

ParserOutput::initFromJson ( JsonUnserializer $unserializer,
array $jsonData )
protected

Initialize member fields from an array returned by jsonSerialize().

Parameters
JsonUnserializer$unserializer
array$jsonData

Reimplemented from CacheTime.

Definition at line 2677 of file ParserOutput.php.

◆ isLinkInternal()

static ParserOutput::isLinkInternal ( $internal,
$url )
static

Checks, if a url is pointing to the own server.

Parameters
string$internalThe server to check against
string$urlThe url to check
Returns
bool
Access: internal

Definition at line 1117 of file ParserOutput.php.

◆ mergeHtmlMetaDataFrom()

ParserOutput::mergeHtmlMetaDataFrom ( ParserOutput $source)

Merges HTML metadata such as head items, JS config vars, and HTTP cache control info from $source into this ParserOutput.

This should be used whenever the HTML in $source has been somehow merged into the HTML of this ParserOutput.

Parameters
ParserOutput$source

Definition at line 2251 of file ParserOutput.php.

◆ mergeInternalMetaDataFrom()

ParserOutput::mergeInternalMetaDataFrom ( ParserOutput $source)

Merges internal metadata such as flags, accessed options, and profiling info from $source into this ParserOutput.

This should be used whenever the state of $source has any impact on the state of this ParserOutput.

Parameters
ParserOutput$source

Definition at line 2215 of file ParserOutput.php.

◆ mergeTrackingMetaDataFrom()

ParserOutput::mergeTrackingMetaDataFrom ( ParserOutput $source)

Merges dependency tracking metadata such as backlinks, images used, and extension data from $source into this ParserOutput.

This allows dependency tracking to be done for the combined output of multiple content slots.

Parameters
ParserOutput$source

Definition at line 2331 of file ParserOutput.php.

◆ newFromJsonArray()

static ParserOutput::newFromJsonArray ( JsonUnserializer $unserializer,
array $json )
static

Creates a new instance of the class and initialized it from the $json array.

Parameters
JsonUnserializer$unserializeran instance of JsonUnserializer to use for nested properties if they need special care.
array$json
Returns
JsonUnserializable

Reimplemented from CacheTime.

Definition at line 2666 of file ParserOutput.php.

◆ preventClickjacking()

ParserOutput::preventClickjacking ( $flag)

Get or set the prevent-clickjacking flag.

Since
1.24
Parameters
bool | null$flagNew flag value, or null to leave it unchanged
Returns
bool Old flag value
Deprecated
since 1.38: use ::setPreventClickjacking() or ::getPreventClickjacking()

Definition at line 2115 of file ParserOutput.php.

◆ resetParseStartTime()

ParserOutput::resetParseStartTime ( )

Resets the parse start timestamps for future calls to getTimeSinceStart()

Since
1.22

Definition at line 1908 of file ParserOutput.php.

◆ setCategories()

ParserOutput::setCategories ( array $c)

Overwrite the category map.

Parameters
array<string,string>$c Map of category names to sort keys
Since
1.38

Definition at line 1017 of file ParserOutput.php.

◆ setCategoryLinks()

ParserOutput::setCategoryLinks ( $cl)
Deprecated
since 1.38, use ::setCategories() instead.

Definition at line 950 of file ParserOutput.php.

References wfDeprecated(), and wfSetVar().

◆ setDisplayTitle()

ParserOutput::setDisplayTitle ( $text)

Override the title to be used for display.

Note
this is assumed to have been validated (check equal normalisation, etc.)
this is expected to be safe HTML, ready to be served to the client.
Parameters
string$textDesired title text

Definition at line 1417 of file ParserOutput.php.

◆ setEnableOOUI()

ParserOutput::setEnableOOUI ( bool $enable = false)

Enables OOUI, if true, in any OutputPage instance this ParserOutput object is added to.

Since
1.26
Parameters
bool$enableIf OOUI should be enabled or not

Definition at line 1037 of file ParserOutput.php.

◆ setExtensionData()

ParserOutput::setExtensionData ( $key,
$value )

Attaches arbitrary data to this ParserObject.

This can be used to store some information in the ParserOutput object for later use during page output. The data will be cached along with the ParserOutput object, but unlike data set using setPageProperty(), it is not recorded in the database.

This method is provided to overcome the unsafe practice of attaching extra information to a ParserObject by directly assigning member variables.

To use setExtensionData() to pass extension information from a hook inside the parser to a hook in the page output, use this in the parser hook:

Example:
$parser->getOutput()->setExtensionData( 'my_ext_foo', '...' );

And then later, in OutputPageParserOutput or similar:

Example:
$output->getExtensionData( 'my_ext_foo' );

In MediaWiki 1.20 and older, you have to use a custom member variable within the ParserOutput object:

Example:
$parser->getOutput()->my_ext_foo = '...';
Note
Only scalar values, e.g. numbers, strings, arrays or MediaWiki\Json\JsonUnserializable instances are supported as a value. Attempt to set other class instance as extension data will break ParserCache for the page.
Since MW 1.38 the practice of setting conflicting values for the same key has been deprecated. As with ::setJsConfigVar(), if you set the same key multiple times on a ParserOutput, it is expected that the value will be identical each time. If you want to collect multiple pieces of data under a single key, use ::appendExtensionData().
Parameters
string$keyThe key for accessing the data. Extensions should take care to avoid conflicts in naming keys. It is suggested to use the extension's name as a prefix.
mixed | JsonUnserializable$valueThe value to set. Setting a value to null is equivalent to removing the value.
Since
1.21

Definition at line 1810 of file ParserOutput.php.

◆ setFlag()

ParserOutput::setFlag ( $flag)

Attach a flag to the output so that it can be checked later to handle special cases.

Parameters
string$flag
Deprecated
since 1.38; use ::setOutputFlag()

Definition at line 1493 of file ParserOutput.php.

◆ setHideNewSection()

ParserOutput::setHideNewSection ( bool $value)
Parameters
bool$valueHide the new section link?

Definition at line 1088 of file ParserOutput.php.

◆ setIndexPolicy()

ParserOutput::setIndexPolicy ( $policy)

Definition at line 976 of file ParserOutput.php.

◆ setIndicator()

ParserOutput::setIndicator ( $id,
$content )
Parameters
string$id
string$content
Since
1.25

Definition at line 1026 of file ParserOutput.php.

◆ setJsConfigVar()

ParserOutput::setJsConfigVar ( string $key,
$value )

Add a variable to be set in mw.config in JavaScript.

In order to ensure the result is independent of the parse order, the values set here must be unique – that is, you can pass the same $key multiple times but ONLY if the $value is identical each time. If you want to collect multiple pieces of data under a single key, use ::appendJsConfigVar().

Parameters
string$keyKey to use under mw.config
mixed | null$valueValue of the configuration variable.
Since
1.38

Definition at line 1294 of file ParserOutput.php.

◆ setLanguage()

ParserOutput::setLanguage ( Bcp47Code $lang)

Set the primary language of the output.

See the discussion and caveats in ::getLanguage().

Parameters
Bcp47Code$langThe primary language for this output, including any variant specification.
Since
1.40

Definition at line 1483 of file ParserOutput.php.

◆ setLanguageLinks()

ParserOutput::setLanguageLinks ( $ll)

Definition at line 943 of file ParserOutput.php.

References wfSetVar().

◆ setLimitReportData()

ParserOutput::setLimitReportData ( $key,
$value )

Sets parser limit report data for a key.

The key is used as the prefix for various messages used for formatting:

  • $key: The label for the field in the limit report
  • $key-value-text: Message used to format the value in the "NewPP limit report" HTML comment. If missing, uses $key-format.
  • $key-value-html: Message used to format the value in the preview limit report table. If missing, uses $key-format.
  • $key-value: Message used to format the value. If missing, uses "$1".

Note that all values are interpreted as wikitext, and so should be encoded with htmlspecialchars() as necessary, but should avoid complex HTML for display in the "NewPP limit report" comment.

Since
1.22
Parameters
string$keyMessage key
mixed$valueAppropriate for Message::params()

Definition at line 1951 of file ParserOutput.php.

◆ setNewSection()

ParserOutput::setNewSection ( $value)

Definition at line 1081 of file ParserOutput.php.

◆ setNoGallery()

ParserOutput::setNoGallery ( $value)

Definition at line 805 of file ParserOutput.php.

◆ setOutputFlag()

ParserOutput::setOutputFlag ( string $name,
bool $val = true )

Provides a uniform interface to various boolean flags stored in the ParserOutput.

Flags internal to MediaWiki core should have names which are constants in ParserOutputFlags. Extensions should use setExtensionData() rather than creating new flags with ::setOutputFlag() in order to prevent namespace conflicts.

Flags are always combined with OR. That is, the flag is set in the resulting ParserOutput if the flag is set in any of the fragments composing the ParserOutput.

Note
The combination policy means that a ParserOutput may end up with both INDEX_POLICY and NO_INDEX_POLICY set. It is expected that NO_INDEX_POLICY "wins" in that case. (T16899) (This resolution is implemented in ::getIndexPolicy().)
Parameters
string$nameA flag name
bool$val
Since
1.38

Definition at line 1680 of file ParserOutput.php.

Referenced by WikitextContentHandler\fillParserOutput().

◆ setPageProperty()

ParserOutput::setPageProperty ( string $name,
$value )

Set a page property to be stored in the page_props database table.

page_props is a key value store indexed by the page ID. This allows the parser to set a property on a page which can then be quickly retrieved given the page ID or via a DB join when given the page title.

Since 1.23, page_props are also indexed by numeric value, to allow for efficient "top k" queries of pages wrt a given property.

setPageProperty() is thus used to propagate properties from the parsed page to request contexts other than a page view of the currently parsed article.

Some applications examples:

  • To implement hidden categories, hiding pages from category listings by storing a page property.
  • Overriding the displayed article title (ParserOutput::setDisplayTitle()).
  • To implement image tagging, for example displaying an icon on an image thumbnail to indicate that it is listed for deletion on Wikimedia Commons. This is not actually implemented, yet but would be pretty cool.
Note
It is strongly recommended that only strings be used for $value. Although any JSON-serializable value can be stored/fetched in ParserOutput, when the values are stored to the database (in deferred/LinksUpdate/PagePropsTable.php) they will be stringified: booleans will be converted to '0' and '1', null will become '', and everything else will be cast to string. Page properties obtained from the PageProps service will always be strings.
Do not use setPageProperty() to set a property which is only used in a context where the ParserOutput object itself is already available, for example a normal page view. There is no need to save such a property in the database since the text is already parsed. You can just hook OutputPageParserOutput and get your data out of the ParserOutput object.

If you are writing an extension where you want to set a property in the parser which is used by an OutputPageParserOutput hook, you have to associate the extension data directly with the ParserOutput object. Since MediaWiki 1.21, you should use setExtensionData() to do this:

Example:
$parser->getOutput()->setExtensionData( 'my_ext_foo', '...' );

And then later, in OutputPageParserOutput or similar:

Example:
$output->getExtensionData( 'my_ext_foo' );
Parameters
string$name
int | float | string | bool | null$value
Since
1.38

Definition at line 1620 of file ParserOutput.php.

◆ setPreventClickjacking()

ParserOutput::setPreventClickjacking ( bool $flag)

Set the prevent-clickjacking flag.

Parameters
bool$flagNew flag value
Since
1.38

Definition at line 2092 of file ParserOutput.php.

◆ setProperty()

ParserOutput::setProperty ( $name,
$value )

Sets a page property to be stored in the page_props database table.

Parameters
string$name
int | float | string | bool | null$value
Deprecated
since 1.38, renamed to ::setPageProperty()

Definition at line 1520 of file ParserOutput.php.

◆ setRevisionTimestampUsed()

ParserOutput::setRevisionTimestampUsed ( $timestamp)
Parameters
string$timestampTS_MW timestamp
Since
1.34

Definition at line 646 of file ParserOutput.php.

◆ setRevisionUsedSha1Base36()

ParserOutput::setRevisionUsedSha1Base36 ( $hash)
Parameters
string$hashLowercase SHA-1 base 36 hash
Since
1.34

Definition at line 662 of file ParserOutput.php.

◆ setSections()

ParserOutput::setSections ( array $sectionArray)
Parameters
array$sectionArray
Returns
array Previous value of ::getSections()

Definition at line 970 of file ParserOutput.php.

◆ setSpeculativePageIdUsed()

ParserOutput::setSpeculativePageIdUsed ( $id)
Parameters
int$id
Since
1.34

Definition at line 630 of file ParserOutput.php.

◆ setSpeculativeRevIdUsed()

ParserOutput::setSpeculativeRevIdUsed ( $id)
Parameters
int$id
Since
1.28

Definition at line 614 of file ParserOutput.php.

◆ setText()

ParserOutput::setText ( $text)

Set the text of the ParserOutput.

If you did not generate html, pass null to mark it as such.

Since
1.39 You can now pass null to this function
Parameters
string | null$textHTML content of ParserOutput or null if not generated
Returns
string|null Previous value of ParserOutput's text

Definition at line 939 of file ParserOutput.php.

References wfSetVar().

Referenced by CssContentHandler\fillParserOutput(), FallbackContentHandler\fillParserOutput(), JavaScriptContentHandler\fillParserOutput(), TextContentHandler\fillParserOutput(), JsonContentHandler\fillParserOutput(), WikitextContentHandler\fillParserOutput(), TablePager\getBodyOutput(), and TablePager\getFullOutput().

◆ setTimestamp()

ParserOutput::setTimestamp ( $timestamp)

Definition at line 999 of file ParserOutput.php.

References wfSetVar().

Referenced by MediaWiki\Parser\RevisionOutputCache\save().

◆ setTitleText()

ParserOutput::setTitleText ( $t)

Definition at line 955 of file ParserOutput.php.

References $t, and wfSetVar().

◆ setTOCData()

ParserOutput::setTOCData ( TOCData $tocData)
Parameters
TOCData$tocDataTable of contents data for the page

Definition at line 962 of file ParserOutput.php.

Referenced by SpecialVersion\execute(), and SpecialEditWatchlist\executeViewEditWatchlist().

◆ setTOCHTML()

ParserOutput::setTOCHTML ( $tochtml)
Access: internal
Deprecated
since 1.40 T293513: We can remove this once we get rid of MW 1.38 and older parsercache serialization tests since those serialized files have artificial TOC data (which we cannot replicate via on-demand TOC generation).

Definition at line 994 of file ParserOutput.php.

References wfDeprecated(), and wfSetVar().

◆ toJsonArray()

ParserOutput::toJsonArray ( )
protected

Returns a JSON serializable structure representing this ParserOutput instance.

See also
newFromJson()
Returns
array

Reimplemented from CacheTime.

Definition at line 2588 of file ParserOutput.php.

◆ unsetPageProperty()

ParserOutput::unsetPageProperty ( string $name)

Remove a page property.

Parameters
string$nameThe page property name.
Since
1.38

Definition at line 1644 of file ParserOutput.php.

◆ unsetProperty()

ParserOutput::unsetProperty ( $name)
Parameters
string$name
Deprecated
since 1.38, renamed to ::unsetPageProperty()

Definition at line 1544 of file ParserOutput.php.

◆ updateRuntimeAdaptiveExpiry()

ParserOutput::updateRuntimeAdaptiveExpiry ( $ttl)

Lower the runtime adaptive TTL to at most this value.

Parameters
int$ttl
Since
1.28

Definition at line 2130 of file ParserOutput.php.

Member Data Documentation

◆ MW_MERGE_STRATEGY_KEY

const ParserOutput::MW_MERGE_STRATEGY_KEY = '_mw-strategy'
Access: internal
Since
1.38

Definition at line 70 of file ParserOutput.php.

◆ MW_MERGE_STRATEGY_UNION

const ParserOutput::MW_MERGE_STRATEGY_UNION = 'union'

Merge strategy to use for ParserOutput accumulators: "union" means that values are strings, stored as a set, and exposed as a PHP associative array mapping from values to true.

This constant should be treated as

Access: internal
until we expose alternative merge strategies for external use.
Access: internal
Since
1.38

Definition at line 82 of file ParserOutput.php.

◆ SUPPORTS_STATELESS_TRANSFORMS

const ParserOutput::SUPPORTS_STATELESS_TRANSFORMS = 1

Feature flags to indicate to extensions that MediaWiki core supports and uses getText() stateless transforms.

Since
1.31

Definition at line 59 of file ParserOutput.php.

◆ SUPPORTS_UNWRAP_TRANSFORM

const ParserOutput::SUPPORTS_UNWRAP_TRANSFORM = 1
Since
1.31

Definition at line 64 of file ParserOutput.php.


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