MediaWiki  master
ParserOutput Class Reference
Inheritance diagram for ParserOutput:
Collaboration diagram for ParserOutput:

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

const SUPPORTS_STATELESS_TRANSFORMS = 1
 Feature flags to indicate to extensions that MediaWiki core supports and uses getText() stateless transforms. More...
 
const SUPPORTS_UNWRAP_TRANSFORM = 1
 

Protected Member Functions

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

Static Private Member Functions

static detectAndDecodeBinary (array $properties)
 Finds any associative arrays that represent encoded binary strings, and replaces them with the decoded binary data. More...
 
static detectAndEncodeBinary (array $properties)
 Finds any non-utf8 strings in the given array and replaces them with an associative array that wraps a base64 encoded version of the data. More...
 
static getTimes ( $clock=null)
 
static merge2D (array $a, array $b)
 
static mergeList (array $a, array $b)
 
static mergeMap (array $a, array $b)
 
static mergeMixedList (array $a, array $b)
 
static useEachMinValue (array $a, array $b)
 
static useMaxValue ( $a, $b)
 
static useMinValue ( $a, $b)
 

Private Attributes

array< string, string > $mCategories
 Map of category names to sort keys. More...
 
bool $mEnableOOUI = false
 Whether OOUI should be enabled. More...
 
array $mExtensionData = []
 extra data used by extensions. More...
 
array $mExternalLinks = []
 External link URLs, in the key only. More...
 
array $mExtraDefaultSrcs = []
 Extra default-src for CSP [Everything but script and style]. More...
 
array $mExtraScriptSrcs = []
 Extra script-src for CSP. More...
 
array $mExtraStyleSrcs = []
 Extra style-src for CSP. More...
 
array $mFileSearchOptions = []
 DB keys of the images used mapped to sha1 and MW timestamp. More...
 
array $mFlags = []
 Generic flags. More...
 
array $mHeadItems = []
 Items to put in the <head> section. More...
 
bool $mHideNewSection = false
 Hide the new section link? More...
 
array $mImages = []
 DB keys of the images used, in the array key only. More...
 
string $mIndexPolicy = ''
 'index' or 'noindex'? Any other value will result in no change. More...
 
array $mIndicators = []
 Page status indicators, usually displayed in top-right corner. More...
 
array $mInterwikiLinks = []
 2-D map of prefix/DBK (in keys only) for the inline interwiki links in the document. More...
 
array $mJsConfigVars = []
 JavaScript config variable for mw.config combined with this page. More...
 
array $mLanguageLinks
 List of the full text of language links, in the order they appear. More...
 
array $mLimitReportData = []
 Parser limit report data. More...
 
array $mLimitReportJSData = []
 Parser limit report data for JSON. More...
 
int[][] $mLinks = []
 2-D map of NS/DBK to ID for the links in the document. More...
 
array $mLinksSpecial = []
 Keys are DBKs for the links to special pages in the document. More...
 
int $mMaxAdaptiveExpiry = INF
 Upper bound of expiry based on parse duration. More...
 
array $mModules = []
 Modules to be loaded by ResourceLoader. More...
 
array $mModuleStyles = []
 Modules of which only the CSSS will be loaded by ResourceLoader. More...
 
bool $mNewSection = false
 Show a new section link? More...
 
bool $mNoGallery = false
 No gallery on category page? (NOGALLERY). More...
 
array $mOutputHooks = []
 Hook tags as per $wgParserOutputHooks. More...
 
array $mParseStartTime = []
 Timestamps for getTimeSinceStart(). More...
 
bool $mPreventClickjacking = false
 Whether to emit X-Frame-Options: DENY. More...
 
array $mProperties = []
 Name/value pairs to be cached in the DB. More...
 
array $mSections = []
 Table of contents. More...
 
int null $mSpeculativeRevId
 Assumed rev ID for {{REVISIONID}} if no revision is set. More...
 
array $mTemplateIds = []
 2-D map of NS/DBK to rev ID for the template references. More...
 
array $mTemplates = []
 2-D map of NS/DBK to ID for the template references. More...
 
string null $mText = null
 The output text. More...
 
string $mTimestamp
 Timestamp of the revision. More...
 
string $mTitleText
 Title text of the chosen language variant, as HTML. More...
 
string $mTOCHTML = ''
 HTML of the TOC. More...
 
array $mWarnings = []
 Warning text to be returned to the user. More...
 
 $mWrapperDivClasses = []
 string CSS classes to use for the wrapping div, stored in the array keys. More...
 
int null $revisionTimestampUsed
 Assumed rev timestamp for {{REVISIONTIMESTAMP}} if no revision is set. More...
 
string null $revisionUsedSha1Base36
 SHA-1 base 36 hash of any self-transclusion. More...
 
int null $speculativePageIdUsed
 Assumed page ID for {{PAGEID}} if no revision is set. More...
 
const EDITSECTION_REGEX
 
const FAST_AR_TTL = 60
 
const MIN_AR_TTL = 15
 
const PARSE_FAST_SEC = 0.100
 
const PARSE_SLOW_SEC = 1.0
 
const SLOW_AR_TTL = 3600
 

Additional Inherited Members

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

Detailed Description

Definition at line 36 of file ParserOutput.php.

Constructor & Destructor Documentation

◆ __construct()

ParserOutput::__construct (   $text = '',
  $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.
array$languageLinks
array$categoryLinks
bool$unused
string$titletext

Definition at line 290 of file ParserOutput.php.

Member Function Documentation

◆ __get()

ParserOutput::__get (   $name)

Reimplemented from CacheTime.

Definition at line 2133 of file ParserOutput.php.

References wfDeprecatedMsg().

◆ __set()

ParserOutput::__set (   $name,
  $value 
)

Reimplemented from CacheTime.

Definition at line 2148 of file ParserOutput.php.

References wfDeprecatedMsg().

◆ __sleep()

ParserOutput::__sleep ( )

Definition at line 1730 of file ParserOutput.php.

◆ __wakeup()

ParserOutput::__wakeup ( )

Reimplemented from CacheTime.

Definition at line 2125 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 516 of file ParserOutput.php.

Referenced by 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 838 of file ParserOutput.php.

Referenced by TrackingCategories\addTrackingCategory().

◆ addExternalLink()

ParserOutput::addExternalLink (   $url)

◆ 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 1679 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 1701 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 1689 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 | bool$tag

Definition at line 1058 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 1007 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 1040 of file ParserOutput.php.

Referenced by addLink().

◆ 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

Definition at line 1089 of file ParserOutput.php.

References $keys.

Referenced by addOutputPageMetadata().

◆ addLanguageLink()

ParserOutput::addLanguageLink (   $t)

Definition at line 871 of file ParserOutput.php.

References $t.

◆ 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 971 of file ParserOutput.php.

References addInterwikiLink(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), MediaWiki\Linker\LinkTarget\isExternal(), NS_FILE, NS_MEDIA, and NS_SPECIAL.

Referenced by WikitextContentHandler\fillParserOutput().

◆ addModules()

ParserOutput::addModules (   $modules)
See also
OutputPage::addModules
Parameters
string | array$modules

Definition at line 1070 of file ParserOutput.php.

References $modules.

Referenced by addOutputPageMetadata().

◆ addModuleStyles()

ParserOutput::addModuleStyles (   $modules)
See also
OutputPage::addModuleStyles
Parameters
string | array$modules

Definition at line 1078 of file ParserOutput.php.

References $modules.

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

◆ addOutputHook()

ParserOutput::addOutputHook (   $hook,
  $data = false 
)

Definition at line 897 of file ParserOutput.php.

◆ addOutputPageMetadata()

ParserOutput::addOutputPageMetadata ( OutputPage  $out)

◆ 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 1021 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.

Todo:
Migrate some code to TrackingCategories
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 1133 of file ParserOutput.php.

References wfDeprecated().

◆ addWarning()

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

Definition at line 878 of file ParserOutput.php.

References $s, and wfDeprecated().

◆ 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 889 of file ParserOutput.php.

References $args, $s, and wfMessage().

◆ 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 525 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 533 of file ParserOutput.php.

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

◆ detectAndDecodeBinary()

static ParserOutput::detectAndDecodeBinary ( array  $properties)
staticprivate

Finds any associative arrays that represent encoded binary strings, and replaces them with the decoded binary data.

Parameters
array$properties
Returns
array

Definition at line 2113 of file ParserOutput.php.

Referenced by initFromJson().

◆ detectAndEncodeBinary()

static ParserOutput::detectAndEncodeBinary ( array  $properties)
staticprivate

Finds any non-utf8 strings in the given array and replaces them with an associative array that wraps a base64 encoded version of the data.

Inverse of detectAndDecodeBinary().

Parameters
array$properties
Returns
array

Definition at line 2089 of file ParserOutput.php.

Referenced by toJsonArray().

◆ finalizeAdaptiveCacheExpiry()

ParserOutput::finalizeAdaptiveCacheExpiry ( )

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

Since
1.28

Definition at line 1710 of file ParserOutput.php.

References FAST_AR_TTL, getTimeSinceStart(), and CacheTime\updateCacheExpiry().

◆ getAllFlags()

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

Definition at line 1194 of file ParserOutput.php.

◆ getCategories()

& ParserOutput::getCategories ( )

◆ 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 636 of file ParserOutput.php.

References getCategoryNames(), and 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 648 of file ParserOutput.php.

Referenced by MediaWiki\Search\ParserOutputSearchDataExtractor\getCategories(), and getCategoryLinks().

◆ 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 1163 of file ParserOutput.php.

References $t, and getTitleText().

◆ getEnableOOUI()

ParserOutput::getEnableOOUI ( )

Definition at line 766 of file ParserOutput.php.

References $mEnableOOUI.

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

◆ 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 1502 of file ParserOutput.php.

◆ getExternalLinks()

& ParserOutput::getExternalLinks ( )

◆ getExtraCSPDefaultSrcs()

ParserOutput::getExtraCSPDefaultSrcs ( )

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

Since
1.35
Returns
array

Definition at line 775 of file ParserOutput.php.

References $mExtraDefaultSrcs.

Referenced by OutputPage\addParserOutputMetadata().

◆ getExtraCSPScriptSrcs()

ParserOutput::getExtraCSPScriptSrcs ( )

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

Since
1.35
Returns
array

Definition at line 784 of file ParserOutput.php.

References $mExtraScriptSrcs.

Referenced by OutputPage\addParserOutputMetadata().

◆ getExtraCSPStyleSrcs()

ParserOutput::getExtraCSPStyleSrcs ( )

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

Since
1.35
Returns
array

Definition at line 793 of file ParserOutput.php.

References $mExtraStyleSrcs.

Referenced by OutputPage\addParserOutputMetadata().

◆ getFileSearchOptions()

& ParserOutput::getFileSearchOptions ( )

Definition at line 699 of file ParserOutput.php.

References $mFileSearchOptions.

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:
Use ::getOutputFlag()

Definition at line 1186 of file ParserOutput.php.

Referenced by getOutputFlag().

◆ getHeadItems()

ParserOutput::getHeadItems ( )

Definition at line 715 of file ParserOutput.php.

References $mHeadItems.

Referenced by OutputPage\addParserOutputMetadata().

◆ getHideNewSection()

ParserOutput::getHideNewSection ( )

Definition at line 921 of file ParserOutput.php.

References $mHideNewSection.

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

◆ getImages()

& ParserOutput::getImages ( )

Definition at line 695 of file ParserOutput.php.

References $mImages.

Referenced by LinksUpdate\__construct(), and OutputPage\addParserOutputMetadata().

◆ getIndexPolicy()

ParserOutput::getIndexPolicy ( )

Definition at line 743 of file ParserOutput.php.

References $mIndexPolicy.

Referenced by getOutputFlag().

◆ getIndicators()

ParserOutput::getIndicators ( )
Returns
array
Since
1.25

Definition at line 660 of file ParserOutput.php.

References $mIndicators.

Referenced by OutputPage\addParserOutputMetadata().

◆ getInterwikiLinks()

ParserOutput::getInterwikiLinks ( )

Definition at line 627 of file ParserOutput.php.

References $mInterwikiLinks.

Referenced by LinksUpdate\__construct().

◆ getJsConfigVars()

ParserOutput::getJsConfigVars ( )
Returns
array
Since
1.23

Definition at line 731 of file ParserOutput.php.

References $mJsConfigVars.

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

◆ getLanguageLinks()

& ParserOutput::getLanguageLinks ( )

Definition at line 623 of file ParserOutput.php.

References $mLanguageLinks.

Referenced by LinksUpdate\__construct(), and OutputPage\addParserOutputMetadata().

◆ getLimitReportData()

ParserOutput::getLimitReportData ( )

Definition at line 758 of file ParserOutput.php.

References $mLimitReportData.

◆ getLimitReportJSData()

ParserOutput::getLimitReportJSData ( )

Definition at line 762 of file ParserOutput.php.

References $mLimitReportJSData.

Referenced by OutputPage\addParserOutputMetadata().

◆ getLinks()

& ParserOutput::getLinks ( )

◆ getLinksSpecial()

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

Definition at line 683 of file ParserOutput.php.

References $mLinksSpecial.

◆ getModules()

ParserOutput::getModules ( )

Definition at line 719 of file ParserOutput.php.

References $mModules.

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

◆ getModuleStyles()

ParserOutput::getModuleStyles ( )

◆ getNewSection()

ParserOutput::getNewSection ( )

Definition at line 925 of file ParserOutput.php.

References $mNewSection.

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

◆ getNoGallery()

ParserOutput::getNoGallery ( )

Definition at line 711 of file ParserOutput.php.

References $mNoGallery.

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

◆ 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 1411 of file ParserOutput.php.

References getEnableOOUI(), getFlag(), getHideNewSection(), getIndexPolicy(), getNewSection(), getNoGallery(), and getPreventClickjacking().

Referenced by MediaWiki\Revision\RenderedRevision\outputVariesOnRevisionMetaData(), and MediaWiki\Storage\PageEditStash\storeStashValue().

◆ getOutputHooks()

ParserOutput::getOutputHooks ( )

Definition at line 735 of file ParserOutput.php.

References $mOutputHooks.

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 1338 of file ParserOutput.php.

References $mProperties.

Referenced by LinksUpdate\__construct(), and getProperties().

◆ getPageProperty()

ParserOutput::getPageProperty ( string  $name)

Look up a page property.

Parameters
string$nameThe page property name to look up.
Returns
int|float|string|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.
Since
1.38

Definition at line 1320 of file ParserOutput.php.

Referenced by TrackingCategories\addTrackingCategory(), and getProperty().

◆ getPreventClickjacking()

ParserOutput::getPreventClickjacking ( )

Get the prevent-clickjacking flag.

Returns
bool Flag value
Since
1.38

Definition at line 1637 of file ParserOutput.php.

References $mPreventClickjacking.

Referenced by OutputPage\addParserOutputMetadata(), getOutputFlag(), and preventClickjacking().

◆ getProperties()

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

Definition at line 1236 of file ParserOutput.php.

References getPageProperties(), and 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()

Definition at line 1218 of file ParserOutput.php.

References getPageProperty(), and 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 321 of file ParserOutput.php.

References $mText.

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

◆ getRevisionTimestampUsed()

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

Definition at line 592 of file ParserOutput.php.

References $revisionTimestampUsed.

Referenced by MediaWiki\Revision\RenderedRevision\outputVariesOnRevisionMetaData().

◆ getRevisionUsedSha1Base36()

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

Definition at line 619 of file ParserOutput.php.

References $revisionUsedSha1Base36.

Referenced by MediaWiki\Revision\RenderedRevision\outputVariesOnRevisionMetaData().

◆ getSections()

ParserOutput::getSections ( )
Returns
array

Definition at line 671 of file ParserOutput.php.

References $mSections.

Referenced by Article\doOutputFromParserCache().

◆ getSpeculativePageIdUsed()

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

Definition at line 576 of file ParserOutput.php.

References $speculativePageIdUsed.

Referenced by MediaWiki\Revision\RenderedRevision\outputVariesOnRevisionMetaData().

◆ getSpeculativeRevIdUsed()

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

Definition at line 560 of file ParserOutput.php.

References $mSpeculativeRevId.

Referenced by MediaWiki\Revision\RenderedRevision\outputVariesOnRevisionMetaData().

◆ getTemplateIds()

& ParserOutput::getTemplateIds ( )

Definition at line 691 of file ParserOutput.php.

References $mTemplateIds.

Referenced by OutputPage\addParserOutputMetadata().

◆ getTemplates()

& ParserOutput::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.
  • 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
Returns
string HTML
-taint escaped

Definition at line 360 of file ParserOutput.php.

References Sanitizer\decodeCharReferences(), Sanitizer\decodeTagAttributes(), Html\element(), RequestContext\getMain(), getRawText(), getTitleText(), getTOCHTML(), getWrapperDivClass(), Title\newFromText(), PROTO_RELATIVE, Html\rawElement(), Parser\replaceTableOfContentsMarker(), Hooks\runner(), wfExpandUrl(), and wfUrlencode().

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

◆ getTimes()

static ParserOutput::getTimes (   $clock = null)
staticprivate

Definition at line 1506 of file ParserOutput.php.

Referenced by getTimeSinceStart(), and resetParseStartTime().

◆ 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 1538 of file ParserOutput.php.

References getTimes().

Referenced by finalizeAdaptiveCacheExpiry().

◆ getTimestamp()

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

Definition at line 754 of file ParserOutput.php.

References $mTimestamp.

Referenced by Article\doOutputFromParserCache().

◆ getTitleText()

ParserOutput::getTitleText ( )

Definition at line 664 of file ParserOutput.php.

References $mTitleText.

Referenced by Article\adjustDisplayTitle(), getDisplayTitle(), and getText().

◆ getTOCHTML()

ParserOutput::getTOCHTML ( )

Definition at line 747 of file ParserOutput.php.

References $mTOCHTML.

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

◆ getWarnings()

ParserOutput::getWarnings ( )

Definition at line 739 of file ParserOutput.php.

◆ getWrapperDivClass()

ParserOutput::getWrapperDivClass ( )

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

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 544 of file ParserOutput.php.

Referenced by getText().

◆ hasDynamicContent()

ParserOutput::hasDynamicContent ( )
See also
ParserOutput::hasReducedExpiry
Returns
bool
Since
1.25

Definition at line 1617 of file ParserOutput.php.

References hasReducedExpiry().

◆ 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 1606 of file ParserOutput.php.

References $wgParserCacheExpireTime, and CacheTime\getCacheExpiry().

Referenced by hasDynamicContent(), and 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 309 of file ParserOutput.php.

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

◆ hideNewSection()

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

Definition at line 916 of file ParserOutput.php.

References setHideNewSection(), and wfDeprecated().

◆ 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 2032 of file ParserOutput.php.

References detectAndDecodeBinary(), and MediaWiki\Json\JsonUnserializer\unserializeArray().

◆ 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 937 of file ParserOutput.php.

Referenced by addExternalLink().

◆ merge2D()

static ParserOutput::merge2D ( array  $a,
array  $b 
)
staticprivate

Definition at line 1897 of file ParserOutput.php.

References $keys.

Referenced by mergeTrackingMetaDataFrom().

◆ 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 mered into the HTML of this ParserOutput.

Parameters
ParserOutput$source

Definition at line 1786 of file ParserOutput.php.

References $source, mergeList(), mergeMap(), and mergeMixedList().

◆ 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 1750 of file ParserOutput.php.

References $source, mergeList(), mergeMap(), useEachMinValue(), useMaxValue(), and wfLogWarning().

◆ mergeList()

static ParserOutput::mergeList ( array  $a,
array  $b 
)
staticprivate

◆ mergeMap()

static ParserOutput::mergeMap ( array  $a,
array  $b 
)
staticprivate

◆ mergeMixedList()

static ParserOutput::mergeMixedList ( array  $a,
array  $b 
)
staticprivate

Definition at line 1885 of file ParserOutput.php.

Referenced by mergeHtmlMetaDataFrom().

◆ 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 1855 of file ParserOutput.php.

References $source, merge2D(), mergeList(), and mergeMap().

◆ 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 2021 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 1650 of file ParserOutput.php.

References getPreventClickjacking(), setPreventClickjacking(), and wfDeprecated().

◆ resetParseStartTime()

ParserOutput::resetParseStartTime ( )

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

Since
1.22

Definition at line 1523 of file ParserOutput.php.

References getTimes().

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

◆ setCategoryLinks()

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

Definition at line 808 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 1150 of file ParserOutput.php.

References setPageProperty(), and setTitleText().

◆ setEnableOOUI()

ParserOutput::setEnableOOUI (   $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 867 of file ParserOutput.php.

Referenced by setOutputFlag().

◆ 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 a extension data will break ParserCache for the page.
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 1483 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:
Use ::setOutputFlag()

Definition at line 1177 of file ParserOutput.php.

◆ setHideNewSection()

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

Definition at line 908 of file ParserOutput.php.

Referenced by hideNewSection(), and setOutputFlag().

◆ setIndexPolicy()

ParserOutput::setIndexPolicy (   $policy)

Definition at line 821 of file ParserOutput.php.

References wfSetVar().

Referenced by setOutputFlag().

◆ setIndicator()

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

Definition at line 856 of file ParserOutput.php.

References $content.

◆ setLanguageLinks()

ParserOutput::setLanguageLinks (   $ll)

Definition at line 801 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 sanity of display in the "NewPP limit report" comment.

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

Definition at line 1566 of file ParserOutput.php.

◆ setNewSection()

ParserOutput::setNewSection (   $value)

Definition at line 901 of file ParserOutput.php.

Referenced by setOutputFlag().

◆ setNoGallery()

ParserOutput::setNoGallery (   $value)

Definition at line 707 of file ParserOutput.php.

Referenced by setOutputFlag().

◆ 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.

Parameters
string$nameA flag name
bool$val
Since
1.38

Definition at line 1356 of file ParserOutput.php.

References setEnableOOUI(), setHideNewSection(), setIndexPolicy(), setNewSection(), setNoGallery(), and setPreventClickjacking().

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
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 can 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' );

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 like numbers and strings are supported as a value. Attempt to use an object or array will not work properly with LinksUpdate.
Parameters
string$name
int | float | string | bool | null$value
Since
1.38

Definition at line 1307 of file ParserOutput.php.

Referenced by setDisplayTitle(), and setProperty().

◆ setPreventClickjacking()

ParserOutput::setPreventClickjacking ( bool  $flag)

Set the prevent-clickjacking flag.

Parameters
bool$flagNew flag value
Since
1.38

Definition at line 1627 of file ParserOutput.php.

Referenced by preventClickjacking(), and setOutputFlag().

◆ 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 1204 of file ParserOutput.php.

References setPageProperty(), and wfDeprecated().

◆ setRevisionTimestampUsed()

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

Definition at line 584 of file ParserOutput.php.

◆ setRevisionUsedSha1Base36()

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

Definition at line 600 of file ParserOutput.php.

◆ setSections()

ParserOutput::setSections (   $toc)

Definition at line 817 of file ParserOutput.php.

References wfSetVar().

◆ setSpeculativePageIdUsed()

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

Definition at line 568 of file ParserOutput.php.

◆ setSpeculativeRevIdUsed()

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

Definition at line 552 of file ParserOutput.php.

◆ setText()

◆ setTimestamp()

ParserOutput::setTimestamp (   $timestamp)

Definition at line 829 of file ParserOutput.php.

References wfSetVar().

Referenced by Parser\RevisionOutputCache\save().

◆ setTitleText()

ParserOutput::setTitleText (   $t)

Definition at line 813 of file ParserOutput.php.

References $t, and wfSetVar().

Referenced by setDisplayTitle().

◆ setTOCHTML()

ParserOutput::setTOCHTML (   $tochtml)

Definition at line 825 of file ParserOutput.php.

References wfSetVar().

◆ toJsonArray()

◆ unsetPageProperty()

ParserOutput::unsetPageProperty ( string  $name)

Remove a page property.

Parameters
string$nameThe page property name.
Since
1.38

Definition at line 1329 of file ParserOutput.php.

Referenced by unsetProperty().

◆ unsetProperty()

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

Definition at line 1227 of file ParserOutput.php.

References unsetPageProperty(), and wfDeprecated().

◆ updateRuntimeAdaptiveExpiry()

ParserOutput::updateRuntimeAdaptiveExpiry (   $ttl)

Lower the runtime adaptive TTL to at most this value.

Parameters
int$ttl
Since
1.28

Definition at line 1665 of file ParserOutput.php.

References CacheTime\updateCacheExpiry().

◆ useEachMinValue()

static ParserOutput::useEachMinValue ( array  $a,
array  $b 
)
staticprivate

Definition at line 1916 of file ParserOutput.php.

References $keys, and useMinValue().

Referenced by mergeInternalMetaDataFrom().

◆ useMaxValue()

static ParserOutput::useMaxValue (   $a,
  $b 
)
staticprivate

Definition at line 1943 of file ParserOutput.php.

Referenced by mergeInternalMetaDataFrom().

◆ useMinValue()

static ParserOutput::useMinValue (   $a,
  $b 
)
staticprivate

Definition at line 1931 of file ParserOutput.php.

Referenced by useEachMinValue().

Member Data Documentation

◆ $mCategories

array<string,string> ParserOutput::$mCategories
private

Map of category names to sort keys.

Definition at line 67 of file ParserOutput.php.

Referenced by getCategories(), and toJsonArray().

◆ $mEnableOOUI

bool ParserOutput::$mEnableOOUI = false
private

Whether OOUI should be enabled.

Definition at line 194 of file ParserOutput.php.

Referenced by getEnableOOUI(), and toJsonArray().

◆ $mExtensionData

array ParserOutput::$mExtensionData = []
private

extra data used by extensions.

Definition at line 204 of file ParserOutput.php.

Referenced by toJsonArray().

◆ $mExternalLinks

array ParserOutput::$mExternalLinks = []
private

External link URLs, in the key only.

Definition at line 117 of file ParserOutput.php.

Referenced by getExternalLinks(), and toJsonArray().

◆ $mExtraDefaultSrcs

array ParserOutput::$mExtraDefaultSrcs = []
private

Extra default-src for CSP [Everything but script and style].

Definition at line 232 of file ParserOutput.php.

Referenced by getExtraCSPDefaultSrcs(), and toJsonArray().

◆ $mExtraScriptSrcs

array ParserOutput::$mExtraScriptSrcs = []
private

Extra script-src for CSP.

Definition at line 227 of file ParserOutput.php.

Referenced by getExtraCSPScriptSrcs(), and toJsonArray().

◆ $mExtraStyleSrcs

array ParserOutput::$mExtraStyleSrcs = []
private

Extra style-src for CSP.

Definition at line 237 of file ParserOutput.php.

Referenced by getExtraCSPStyleSrcs(), and toJsonArray().

◆ $mFileSearchOptions

array ParserOutput::$mFileSearchOptions = []
private

DB keys of the images used mapped to sha1 and MW timestamp.

Definition at line 112 of file ParserOutput.php.

Referenced by getFileSearchOptions(), and toJsonArray().

◆ $mFlags

array ParserOutput::$mFlags = []
private

Generic flags.

Definition at line 242 of file ParserOutput.php.

Referenced by toJsonArray().

◆ $mHeadItems

array ParserOutput::$mHeadItems = []
private

Items to put in the <head> section.

Definition at line 143 of file ParserOutput.php.

Referenced by getHeadItems(), and toJsonArray().

◆ $mHideNewSection

bool ParserOutput::$mHideNewSection = false
private

Hide the new section link?

Definition at line 133 of file ParserOutput.php.

Referenced by getHideNewSection(), and toJsonArray().

◆ $mImages

array ParserOutput::$mImages = []
private

DB keys of the images used, in the array key only.

Definition at line 107 of file ParserOutput.php.

Referenced by getImages(), and toJsonArray().

◆ $mIndexPolicy

string ParserOutput::$mIndexPolicy = ''
private

'index' or 'noindex'? Any other value will result in no change.

Definition at line 199 of file ParserOutput.php.

Referenced by getIndexPolicy(), and toJsonArray().

◆ $mIndicators

array ParserOutput::$mIndicators = []
private

Page status indicators, usually displayed in top-right corner.

Definition at line 72 of file ParserOutput.php.

Referenced by getIndicators(), and toJsonArray().

◆ $mInterwikiLinks

array ParserOutput::$mInterwikiLinks = []
private

2-D map of prefix/DBK (in keys only) for the inline interwiki links in the document.

Definition at line 123 of file ParserOutput.php.

Referenced by getInterwikiLinks(), and toJsonArray().

◆ $mJsConfigVars

array ParserOutput::$mJsConfigVars = []
private

JavaScript config variable for mw.config combined with this page.

Definition at line 158 of file ParserOutput.php.

Referenced by getJsConfigVars(), and toJsonArray().

◆ $mLanguageLinks

array ParserOutput::$mLanguageLinks
private

List of the full text of language links, in the order they appear.

Definition at line 62 of file ParserOutput.php.

Referenced by getLanguageLinks(), and toJsonArray().

◆ $mLimitReportData

array ParserOutput::$mLimitReportData = []
private

Parser limit report data.

Definition at line 209 of file ParserOutput.php.

Referenced by getLimitReportData(), and toJsonArray().

◆ $mLimitReportJSData

array ParserOutput::$mLimitReportJSData = []
private

Parser limit report data for JSON.

Definition at line 212 of file ParserOutput.php.

Referenced by getLimitReportJSData(), and toJsonArray().

◆ $mLinks

int [][] ParserOutput::$mLinks = []
private

2-D map of NS/DBK to ID for the links in the document.

ID=zero for broken.

Definition at line 84 of file ParserOutput.php.

Referenced by getLinks(), and toJsonArray().

◆ $mLinksSpecial

array ParserOutput::$mLinksSpecial = []
private

Keys are DBKs for the links to special pages in the document.

Since
1.35

Definition at line 90 of file ParserOutput.php.

Referenced by getLinksSpecial(), and toJsonArray().

◆ $mMaxAdaptiveExpiry

int ParserOutput::$mMaxAdaptiveExpiry = INF
private

Upper bound of expiry based on parse duration.

Definition at line 267 of file ParserOutput.php.

Referenced by toJsonArray().

◆ $mModules

array ParserOutput::$mModules = []
private

Modules to be loaded by ResourceLoader.

Definition at line 148 of file ParserOutput.php.

Referenced by getModules(), and toJsonArray().

◆ $mModuleStyles

array ParserOutput::$mModuleStyles = []
private

Modules of which only the CSSS will be loaded by ResourceLoader.

Definition at line 153 of file ParserOutput.php.

Referenced by getModuleStyles(), and toJsonArray().

◆ $mNewSection

bool ParserOutput::$mNewSection = false
private

Show a new section link?

Definition at line 128 of file ParserOutput.php.

Referenced by getNewSection(), and toJsonArray().

◆ $mNoGallery

bool ParserOutput::$mNoGallery = false
private

No gallery on category page? (NOGALLERY).

Definition at line 138 of file ParserOutput.php.

Referenced by getNoGallery(), and toJsonArray().

◆ $mOutputHooks

array ParserOutput::$mOutputHooks = []
private

Hook tags as per $wgParserOutputHooks.

Definition at line 163 of file ParserOutput.php.

Referenced by getOutputHooks(), and toJsonArray().

◆ $mParseStartTime

array ParserOutput::$mParseStartTime = []
private

Timestamps for getTimeSinceStart().

Definition at line 217 of file ParserOutput.php.

Referenced by toJsonArray().

◆ $mPreventClickjacking

bool ParserOutput::$mPreventClickjacking = false
private

Whether to emit X-Frame-Options: DENY.

Definition at line 222 of file ParserOutput.php.

Referenced by getPreventClickjacking(), and toJsonArray().

◆ $mProperties

array ParserOutput::$mProperties = []
private

Name/value pairs to be cached in the DB.

Definition at line 179 of file ParserOutput.php.

Referenced by getPageProperties().

◆ $mSections

array ParserOutput::$mSections = []
private

Table of contents.

Definition at line 174 of file ParserOutput.php.

Referenced by getSections(), and toJsonArray().

◆ $mSpeculativeRevId

int null ParserOutput::$mSpeculativeRevId
private
Initial value:
=[,,]
private const SPECULATIVE_FIELDS
'speculativePageIdUsed'
'mSpeculativeRevId'
'revisionTimestampUsed'

Assumed rev ID for {{REVISIONID}} if no revision is set.

Definition at line 252 of file ParserOutput.php.

Referenced by getSpeculativeRevIdUsed(), and toJsonArray().

◆ $mTemplateIds

array ParserOutput::$mTemplateIds = []
private

2-D map of NS/DBK to rev ID for the template references.

ID=zero for broken.

Definition at line 102 of file ParserOutput.php.

Referenced by getTemplateIds(), and toJsonArray().

◆ $mTemplates

array ParserOutput::$mTemplates = []
private

2-D map of NS/DBK to ID for the template references.

ID=zero for broken.

Definition at line 96 of file ParserOutput.php.

Referenced by getTemplates(), and toJsonArray().

◆ $mText

string null ParserOutput::$mText = null
private

The output text.

Definition at line 56 of file ParserOutput.php.

Referenced by getRawText(), and toJsonArray().

◆ $mTimestamp

string ParserOutput::$mTimestamp
private

Timestamp of the revision.

Definition at line 189 of file ParserOutput.php.

Referenced by getTimestamp(), and toJsonArray().

◆ $mTitleText

string ParserOutput::$mTitleText
private

Title text of the chosen language variant, as HTML.

Definition at line 77 of file ParserOutput.php.

Referenced by getTitleText(), and toJsonArray().

◆ $mTOCHTML

string ParserOutput::$mTOCHTML = ''
private

HTML of the TOC.

Definition at line 184 of file ParserOutput.php.

Referenced by getTOCHTML(), and toJsonArray().

◆ $mWarnings

array ParserOutput::$mWarnings = []
private

Warning text to be returned to the user.

Wikitext formatted, in the key only.

Definition at line 169 of file ParserOutput.php.

Referenced by toJsonArray().

◆ $mWrapperDivClasses

ParserOutput::$mWrapperDivClasses = []
private

string CSS classes to use for the wrapping div, stored in the array keys.

If no class is given, no wrapper is added.

Definition at line 264 of file ParserOutput.php.

Referenced by toJsonArray().

◆ $revisionTimestampUsed

int null ParserOutput::$revisionTimestampUsed
private

Assumed rev timestamp for {{REVISIONTIMESTAMP}} if no revision is set.

Definition at line 256 of file ParserOutput.php.

Referenced by getRevisionTimestampUsed(), and toJsonArray().

◆ $revisionUsedSha1Base36

string null ParserOutput::$revisionUsedSha1Base36
private

SHA-1 base 36 hash of any self-transclusion.

Definition at line 259 of file ParserOutput.php.

Referenced by getRevisionUsedSha1Base36(), and toJsonArray().

◆ $speculativePageIdUsed

int null ParserOutput::$speculativePageIdUsed
private

Assumed page ID for {{PAGEID}} if no revision is set.

Definition at line 254 of file ParserOutput.php.

Referenced by getSpeculativePageIdUsed(), and toJsonArray().

◆ EDITSECTION_REGEX

const ParserOutput::EDITSECTION_REGEX
private
Initial value:
=
'#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#s'

Definition at line 269 of file ParserOutput.php.

◆ FAST_AR_TTL

const ParserOutput::FAST_AR_TTL = 60
private

Definition at line 277 of file ParserOutput.php.

Referenced by finalizeAdaptiveCacheExpiry().

◆ MIN_AR_TTL

const ParserOutput::MIN_AR_TTL = 15
private

Definition at line 279 of file ParserOutput.php.

◆ PARSE_FAST_SEC

const ParserOutput::PARSE_FAST_SEC = 0.100
private

Definition at line 275 of file ParserOutput.php.

◆ PARSE_SLOW_SEC

const ParserOutput::PARSE_SLOW_SEC = 1.0
private

Definition at line 276 of file ParserOutput.php.

◆ SLOW_AR_TTL

const ParserOutput::SLOW_AR_TTL = 3600
private

Definition at line 278 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 46 of file ParserOutput.php.

◆ SUPPORTS_UNWRAP_TRANSFORM

const ParserOutput::SUPPORTS_UNWRAP_TRANSFORM = 1
Since
1.31

Definition at line 51 of file ParserOutput.php.


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