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

Public Member Functions

 __construct ( $text='', $languageLinks=[], $categoryLinks=[], $unused=false, $titletext='')
 
 __sleep ()
 Save space for serialization by removing useless values.
 
 addCategory ( $c, $sort)
 
 addExternalLink ( $url)
 
 addHeadItem ( $section, $tag=false)
 Add some text to the "<head>".
 
 addImage ( $name, $timestamp=null, $sha1=null)
 Register a file dependency for this output.
 
 addInterwikiLink ( $title)
 
 addJsConfigVars ( $keys, $value=null)
 Add one or more variables to be set in mw.config in JavaScript.
 
 addLanguageLink ( $t)
 
 addLink (Title $title, $id=null)
 Record a local or interwiki inline link for saving in future link tables.
 
 addModuleMessages ( $modules)
 
 addModules ( $modules)
 
 addModuleScripts ( $modules)
 
 addModuleStyles ( $modules)
 
 addOutputHook ( $hook, $data=false)
 
 addOutputPageMetadata (OutputPage $out)
 Copy items from the OutputPage object into this one.
 
 addTemplate ( $title, $page_id, $rev_id)
 Register a template dependency for this output.
 
 addTrackingCategory ( $msg, $title)
 Add a tracking category, getting the title from a system message, or print a debug message if the title is invalid.
 
 addWarning ( $s)
 
getCategories ()
 
 getCategoryLinks ()
 
 getDisplayTitle ()
 Get the title to be used for display.
 
 getEditSectionTokens ()
 
 getEnableOOUI ()
 
 getExtensionData ( $key)
 Gets extensions data previously attached to this ParserOutput using setExtensionData().
 
getExternalLinks ()
 
getFileSearchOptions ()
 
 getFlag ( $flag)
 
 getHeadItems ()
 
 getHideNewSection ()
 
getImages ()
 
 getIndexPolicy ()
 
 getIndicators ()
 
 getInterwikiLinks ()
 
 getJsConfigVars ()
 
getLanguageLinks ()
 
 getLimitReportData ()
 
getLinks ()
 
 getModuleMessages ()
 
 getModules ()
 
 getModuleScripts ()
 
 getModuleStyles ()
 
 getNewSection ()
 
 getNoGallery ()
 
 getOutputHooks ()
 
 getProperties ()
 
 getProperty ( $name)
 
 getRawText ()
 Get the cacheable text with <mw:editsection> markers still in it.
 
 getSections ()
 
getTemplateIds ()
 
getTemplates ()
 
 getText ()
 
 getTimeSinceStart ( $clock)
 Returns the time since resetParseStartTime() was last called.
 
 getTimestamp ()
 
 getTitleText ()
 
 getTOCEnabled ()
 
 getTOCHTML ()
 
 getUsedOptions ()
 Returns the options from its ParserOptions which have been taken into account to produce this output or false if not available.
 
 getWarnings ()
 
 hasDynamicContent ()
 Check whether the cache TTL was lowered due to dynamic content.
 
 hideNewSection ( $value)
 
 preventClickjacking ( $flag=null)
 Get or set the prevent-clickjacking flag.
 
 recordOption ( $option)
 Tags a parser option for use in the cache key for this parser output.
 
 resetParseStartTime ()
 Resets the parse start timestamps for future calls to getTimeSinceStart()
 
 setCategoryLinks ( $cl)
 
 setDisplayTitle ( $text)
 Override the title to be used for display.
 
 setEditSectionTokens ( $t)
 
 setEnableOOUI ( $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)
 Fairly generic flag setter thingy.
 
 setIndexPolicy ( $policy)
 
 setIndicator ( $id, $content)
 
 setLanguageLinks ( $ll)
 
 setLimitReportData ( $key, $value)
 Sets parser limit report data for a key.
 
 setNewSection ( $value)
 
 setProperty ( $name, $value)
 Set a property to be stored in the page_props database table.
 
 setSections ( $toc)
 
 setText ( $text)
 
 setTimestamp ( $timestamp)
 
 setTitleText ( $t)
 
 setTOCEnabled ( $flag)
 
 setTOCHTML ( $tochtml)
 
 unsetProperty ( $name)
 
- 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 ()
 
 isCacheable ()
 
 isDifferentRevision ( $id)
 Return true if this cached output object is for a different revision of the page.
 
 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.
 

Public Attributes

 $mCategories
 
 $mEditSectionTokens = false
 
 $mEnableOOUI = false
 
 $mExternalLinks = []
 
 $mFileSearchOptions = []
 
 $mHeadItems = []
 
 $mHideNewSection = false
 
 $mImages = []
 
 $mIndicators = []
 
 $mInterwikiLinks = []
 
 $mJsConfigVars = []
 
 $mLanguageLinks
 
 $mLinks = []
 
 $mModules = []
 
 $mModuleScripts = []
 
 $mModuleStyles = []
 
 $mNewSection = false
 
 $mNoGallery = false
 
 $mOutputHooks = []
 
 $mProperties = []
 
 $mSections = []
 
 $mTemplateIds = []
 
 $mTemplates = []
 
 $mText
 
 $mTimestamp
 
 $mTitleText
 
 $mTOCEnabled = true
 
 $mTOCHTML = ''
 
 $mWarnings = []
 
const EDITSECTION_REGEX
 
- Public Attributes inherited from CacheTime
 $mCacheExpiry = null
 
 $mCacheRevisionId = null
 
 $mCacheTime = ''
 
array bool $mUsedOptions
 ParserOptions which have been taken into account to produce output or false if not available.
 
 $mVersion = Parser::VERSION
 

Static Private Member Functions

static getTimes ( $clock=null)
 

Private Attributes

 $mAccessedOptions = []
 
 $mExtensionData = []
 
 $mFlags = []
 
 $mIndexPolicy = ''
 
 $mLimitReportData = []
 
 $mParseStartTime = []
 
 $mPreventClickjacking = false
 

Detailed Description

Definition at line 24 of file ParserOutput.php.

Constructor & Destructor Documentation

◆ __construct()

ParserOutput::__construct (   $text = '',
  $languageLinks = [],
  $categoryLinks = [],
  $unused = false,
  $titletext = '' 
)

Definition at line 214 of file ParserOutput.php.

Member Function Documentation

◆ __sleep()

ParserOutput::__sleep ( )

Save space for serialization by removing useless values.

Returns
array

Definition at line 1040 of file ParserOutput.php.

◆ addCategory()

ParserOutput::addCategory (   $c,
  $sort 
)

Definition at line 443 of file ParserOutput.php.

References $sort.

Referenced by addTrackingCategory().

◆ addExternalLink()

ParserOutput::addExternalLink (   $url)

Definition at line 508 of file ParserOutput.php.

References $wgRegisterInternalExternals, $wgServer, and global.

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

References $section, and $tag.

◆ addImage()

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

Register a file dependency for this output.

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

Definition at line 566 of file ParserOutput.php.

References $name, and $timestamp.

◆ addInterwikiLink()

ParserOutput::addInterwikiLink (   $title)
Parameters
Title$titleTitle object, must be an interwiki link
Exceptions
MWExceptionIf given invalid input

Definition at line 597 of file ParserOutput.php.

References $title.

Referenced by addLink(), and LinkHolderArray\replaceInterwiki().

◆ 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$value[optional] Value of the configuration variable.
Since
1.23

Definition at line 650 of file ParserOutput.php.

References $keys, $value, and as.

Referenced by addOutputPageMetadata(), ProtectionForm\buildForm(), ImagePage\openShowImage(), and MediaWiki\performRequest().

◆ addLanguageLink()

ParserOutput::addLanguageLink (   $t)

Definition at line 465 of file ParserOutput.php.

References $t.

◆ addLink()

ParserOutput::addLink ( Title  $title,
  $id = null 
)

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

Parameters
Title$title
int | null$idOptional known page_id so we can skip the lookup

Definition at line 531 of file ParserOutput.php.

References $title, addInterwikiLink(), NS_FILE, NS_MEDIA, and NS_SPECIAL.

Referenced by LinkHolderArray\doVariants(), WikitextContent\fillParserOutput(), and LinkHolderArray\replaceInternal().

◆ addModuleMessages()

ParserOutput::addModuleMessages (   $modules)
Deprecated:
since 1.26 Use addModules() instead
Parameters
string | array$modules

Definition at line 639 of file ParserOutput.php.

References wfDeprecated().

◆ addModules()

◆ addModuleScripts()

ParserOutput::addModuleScripts (   $modules)

Definition at line 627 of file ParserOutput.php.

References array().

Referenced by addOutputPageMetadata().

◆ addModuleStyles()

ParserOutput::addModuleStyles (   $modules)

◆ addOutputHook()

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

Definition at line 473 of file ParserOutput.php.

◆ addOutputPageMetadata()

ParserOutput::addOutputPageMetadata ( OutputPage  $out)

Copy items from the OutputPage object into this one.

Parameters
OutputPage$out

Definition at line 666 of file ParserOutput.php.

References $out, addJsConfigVars(), addModules(), addModuleScripts(), and addModuleStyles().

◆ addTemplate()

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

Register a template dependency for this output.

Parameters
Title$title
int$page_id
int$rev_id
Returns
void

Definition at line 580 of file ParserOutput.php.

References $title.

◆ addTrackingCategory()

ParserOutput::addTrackingCategory (   $msg,
  $title 
)

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 SpecialTrackingCategories::$coreTrackingCategories, and extensions should add to "TrackingCategories" in their extension.json.

Parameters
string$msgMessage key
Title$titletitle of the page which is being tracked
Returns
bool Whether the addition was successful
Since
1.25

Definition at line 690 of file ParserOutput.php.

References $title, addCategory(), Title\makeTitleSafe(), NS_CATEGORY, NS_SPECIAL, wfDebug(), and wfMessage().

◆ addWarning()

ParserOutput::addWarning (   $s)

Definition at line 469 of file ParserOutput.php.

References $s.

◆ getCategories()

◆ getCategoryLinks()

ParserOutput::getCategoryLinks ( )

Definition at line 283 of file ParserOutput.php.

Referenced by LinkHolderArray\doVariants().

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

Definition at line 741 of file ParserOutput.php.

References $t, and getTitleText().

◆ getEditSectionTokens()

ParserOutput::getEditSectionTokens ( )

Definition at line 306 of file ParserOutput.php.

◆ getEnableOOUI()

ParserOutput::getEnableOOUI ( )

Definition at line 399 of file ParserOutput.php.

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

◆ getExternalLinks()

& ParserOutput::getExternalLinks ( )

Definition at line 330 of file ParserOutput.php.

◆ getFileSearchOptions()

& ParserOutput::getFileSearchOptions ( )

Definition at line 326 of file ParserOutput.php.

◆ getFlag()

ParserOutput::getFlag (   $flag)

Definition at line 757 of file ParserOutput.php.

◆ getHeadItems()

ParserOutput::getHeadItems ( )

Definition at line 338 of file ParserOutput.php.

◆ getHideNewSection()

ParserOutput::getHideNewSection ( )

Definition at line 483 of file ParserOutput.php.

◆ getImages()

& ParserOutput::getImages ( )

Definition at line 322 of file ParserOutput.php.

◆ getIndexPolicy()

ParserOutput::getIndexPolicy ( )

Definition at line 376 of file ParserOutput.php.

◆ getIndicators()

ParserOutput::getIndicators ( )
Since
1.25

Definition at line 294 of file ParserOutput.php.

Referenced by ParserTest\runTest(), and NewParserTest\testParserTest().

◆ getInterwikiLinks()

ParserOutput::getInterwikiLinks ( )

Definition at line 279 of file ParserOutput.php.

◆ getJsConfigVars()

ParserOutput::getJsConfigVars ( )
Since
1.23

Definition at line 364 of file ParserOutput.php.

◆ getLanguageLinks()

& ParserOutput::getLanguageLinks ( )

Definition at line 275 of file ParserOutput.php.

Referenced by ParserTest\runTest(), and NewParserTest\testParserTest().

◆ getLimitReportData()

ParserOutput::getLimitReportData ( )

Definition at line 391 of file ParserOutput.php.

Referenced by EditPage\getPreviewLimitReport().

◆ getLinks()

& ParserOutput::getLinks ( )

Definition at line 310 of file ParserOutput.php.

◆ getModuleMessages()

ParserOutput::getModuleMessages ( )
Deprecated:
since 1.26 Obsolete
Returns
array

Definition at line 358 of file ParserOutput.php.

References wfDeprecated().

◆ getModules()

ParserOutput::getModules ( )

Definition at line 342 of file ParserOutput.php.

◆ getModuleScripts()

ParserOutput::getModuleScripts ( )

Definition at line 346 of file ParserOutput.php.

◆ getModuleStyles()

ParserOutput::getModuleStyles ( )

Definition at line 350 of file ParserOutput.php.

◆ getNewSection()

ParserOutput::getNewSection ( )

Definition at line 486 of file ParserOutput.php.

◆ getNoGallery()

ParserOutput::getNoGallery ( )

Definition at line 334 of file ParserOutput.php.

◆ getOutputHooks()

ParserOutput::getOutputHooks ( )

Definition at line 368 of file ParserOutput.php.

References array().

◆ getProperties()

ParserOutput::getProperties ( )

Definition at line 841 of file ParserOutput.php.

◆ getProperty()

ParserOutput::getProperty (   $name)
Parameters
string$nameThe property name to look up.
Returns
mixed|bool The value previously set using setProperty(). False if null or no value was set for the given property name.
Note
You need to use getProperties() to check for boolean and null properties.

Definition at line 833 of file ParserOutput.php.

References $name.

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

Since
1.27

Definition at line 230 of file ParserOutput.php.

Referenced by WikitextContent\fillParserOutput().

◆ getSections()

ParserOutput::getSections ( )

Definition at line 302 of file ParserOutput.php.

◆ getTemplateIds()

& ParserOutput::getTemplateIds ( )

Definition at line 318 of file ParserOutput.php.

◆ getTemplates()

& ParserOutput::getTemplates ( )

Definition at line 314 of file ParserOutput.php.

◆ getText()

◆ getTimes()

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

Definition at line 943 of file ParserOutput.php.

References $ret, and wfGetRusage().

◆ getTimeSinceStart()

array $mParseStartTime Timestamps for 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 977 of file ParserOutput.php.

◆ getTimestamp()

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

Definition at line 387 of file ParserOutput.php.

◆ getTitleText()

ParserOutput::getTitleText ( )

◆ getTOCEnabled()

ParserOutput::getTOCEnabled ( )

Definition at line 395 of file ParserOutput.php.

◆ getTOCHTML()

ParserOutput::getTOCHTML ( )

Definition at line 380 of file ParserOutput.php.

◆ getUsedOptions()

ParserOutput::getUsedOptions ( )

Returns the options from its ParserOptions which have been taken into account to produce this output or false if not available.

Returns
array

Definition at line 853 of file ParserOutput.php.

◆ getWarnings()

ParserOutput::getWarnings ( )

Definition at line 372 of file ParserOutput.php.

◆ hasDynamicContent()

ParserOutput::hasDynamicContent ( )

Check whether the cache TTL was lowered due to dynamic content.

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.

Returns
bool
Since
1.25

Definition at line 1019 of file ParserOutput.php.

References $wgParserCacheExpireTime, CacheTime\getCacheExpiry(), and global.

◆ hideNewSection()

ParserOutput::hideNewSection (   $value)

Definition at line 480 of file ParserOutput.php.

References $value.

◆ 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

Definition at line 497 of file ParserOutput.php.

References check, http, https, in, is(), link, links, of, or, query, and server.

◆ preventClickjacking()

ParserOutput::preventClickjacking (   $flag = null)

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

Definition at line 1032 of file ParserOutput.php.

References wfSetVar().

Referenced by SpecialContributions\execute().

◆ recordOption()

ParserOutput::recordOption (   $option)

Tags a parser option for use in the cache key for this parser output.

Registered as a watcher at ParserOptions::registerWatcher() by Parser::clearState(). The information gathered here is available via getUsedOptions(), and is used by ParserCache::save().

See also
ParserCache::getKey
ParserCache::save
ParserOptions::addExtraKey
ParserOptions::optionsHash
Parameters
string$option

Definition at line 872 of file ParserOutput.php.

◆ resetParseStartTime()

ParserOutput::resetParseStartTime ( )

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

Since
1.22

Definition at line 962 of file ParserOutput.php.

◆ setCategoryLinks()

ParserOutput::setCategoryLinks (   $cl)

Definition at line 411 of file ParserOutput.php.

References wfSetVar().

Referenced by LinkHolderArray\doVariants().

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

References setProperty(), and setTitleText().

◆ setEditSectionTokens()

ParserOutput::setEditSectionTokens (   $t)

Definition at line 423 of file ParserOutput.php.

References $t, and wfSetVar().

◆ 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 461 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 setProperty(), 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', '...' );
do that in ParserLimitReportFormat instead $parser
Definition hooks.txt:2341

And then later, in OutputPageParserOutput or similar:

Example:
$output->getExtensionData( 'my_ext_foo' );
getExtensionData( $key)
Gets extensions data previously attached to this ParserOutput using setExtensionData().
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
Definition hooks.txt:1048

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

Example:
$parser->getOutput()->my_ext_foo = '...';
Since
1.21
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$valueThe value to set. Setting a value to null is equivalent to removing the value.

Definition at line 916 of file ParserOutput.php.

References $value.

◆ setFlag()

ParserOutput::setFlag (   $flag)

Fairly generic flag setter thingy.

Parameters
string$flag

Definition at line 753 of file ParserOutput.php.

◆ setIndexPolicy()

ParserOutput::setIndexPolicy (   $policy)

Definition at line 427 of file ParserOutput.php.

References wfSetVar().

◆ setIndicator()

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

Definition at line 450 of file ParserOutput.php.

References $content.

◆ setLanguageLinks()

ParserOutput::setLanguageLinks (   $ll)

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

References $value.

◆ setNewSection()

ParserOutput::setNewSection (   $value)

Definition at line 477 of file ParserOutput.php.

References $value.

◆ setProperty()

ParserOutput::setProperty (   $name,
  $value 
)

Set a 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.

setProperty() 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 property.
  • Overriding the displayed article title.
    See also
    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 setProperty() 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 = '...';

Definition at line 821 of file ParserOutput.php.

References $name, and $value.

Referenced by setDisplayTitle().

◆ setSections()

ParserOutput::setSections (   $toc)

Definition at line 419 of file ParserOutput.php.

References wfSetVar().

◆ setText()

◆ setTimestamp()

ParserOutput::setTimestamp (   $timestamp)

Definition at line 435 of file ParserOutput.php.

References $timestamp, and wfSetVar().

◆ setTitleText()

ParserOutput::setTitleText (   $t)

Definition at line 415 of file ParserOutput.php.

References $t, and wfSetVar().

Referenced by setDisplayTitle().

◆ setTOCEnabled()

ParserOutput::setTOCEnabled (   $flag)

Definition at line 439 of file ParserOutput.php.

References wfSetVar().

Referenced by ParserTest\runTest(), and NewParserTest\testParserTest().

◆ setTOCHTML()

ParserOutput::setTOCHTML (   $tochtml)

Definition at line 431 of file ParserOutput.php.

References wfSetVar().

◆ unsetProperty()

ParserOutput::unsetProperty (   $name)

Definition at line 837 of file ParserOutput.php.

References $name.

Member Data Documentation

◆ $mAccessedOptions

ParserOutput::$mAccessedOptions = []
private

Definition at line 184 of file ParserOutput.php.

◆ $mCategories

ParserOutput::$mCategories

Definition at line 39 of file ParserOutput.php.

◆ $mEditSectionTokens

ParserOutput::$mEditSectionTokens = false

Definition at line 149 of file ParserOutput.php.

◆ $mEnableOOUI

ParserOutput::$mEnableOOUI = false

Definition at line 174 of file ParserOutput.php.

◆ $mExtensionData

ParserOutput::$mExtensionData = []
private

Definition at line 189 of file ParserOutput.php.

◆ $mExternalLinks

ParserOutput::$mExternalLinks = []

Definition at line 82 of file ParserOutput.php.

◆ $mFileSearchOptions

ParserOutput::$mFileSearchOptions = []

Definition at line 77 of file ParserOutput.php.

◆ $mFlags

ParserOutput::$mFlags = []
private

Definition at line 209 of file ParserOutput.php.

◆ $mHeadItems

ParserOutput::$mHeadItems = []

Definition at line 108 of file ParserOutput.php.

◆ $mHideNewSection

ParserOutput::$mHideNewSection = false

Definition at line 98 of file ParserOutput.php.

◆ $mImages

ParserOutput::$mImages = []

Definition at line 72 of file ParserOutput.php.

◆ $mIndexPolicy

ParserOutput::$mIndexPolicy = ''
private

Definition at line 179 of file ParserOutput.php.

◆ $mIndicators

ParserOutput::$mIndicators = []

Definition at line 44 of file ParserOutput.php.

◆ $mInterwikiLinks

ParserOutput::$mInterwikiLinks = []

Definition at line 88 of file ParserOutput.php.

◆ $mJsConfigVars

ParserOutput::$mJsConfigVars = []

Definition at line 128 of file ParserOutput.php.

◆ $mLanguageLinks

ParserOutput::$mLanguageLinks

Definition at line 34 of file ParserOutput.php.

◆ $mLimitReportData

ParserOutput::$mLimitReportData = []
private

Definition at line 194 of file ParserOutput.php.

◆ $mLinks

ParserOutput::$mLinks = []

Definition at line 55 of file ParserOutput.php.

◆ $mModules

ParserOutput::$mModules = []

Definition at line 113 of file ParserOutput.php.

◆ $mModuleScripts

ParserOutput::$mModuleScripts = []

Definition at line 118 of file ParserOutput.php.

◆ $mModuleStyles

ParserOutput::$mModuleStyles = []

Definition at line 123 of file ParserOutput.php.

◆ $mNewSection

ParserOutput::$mNewSection = false

Definition at line 93 of file ParserOutput.php.

◆ $mNoGallery

ParserOutput::$mNoGallery = false

Definition at line 103 of file ParserOutput.php.

◆ $mOutputHooks

ParserOutput::$mOutputHooks = []

Definition at line 133 of file ParserOutput.php.

◆ $mParseStartTime

ParserOutput::$mParseStartTime = []
private

Definition at line 199 of file ParserOutput.php.

◆ $mPreventClickjacking

ParserOutput::$mPreventClickjacking = false
private

Definition at line 204 of file ParserOutput.php.

◆ $mProperties

ParserOutput::$mProperties = []

Definition at line 154 of file ParserOutput.php.

◆ $mSections

ParserOutput::$mSections = []

Definition at line 144 of file ParserOutput.php.

◆ $mTemplateIds

ParserOutput::$mTemplateIds = []

Definition at line 67 of file ParserOutput.php.

◆ $mTemplates

ParserOutput::$mTemplates = []

Definition at line 61 of file ParserOutput.php.

◆ $mText

ParserOutput::$mText

Definition at line 28 of file ParserOutput.php.

◆ $mTimestamp

ParserOutput::$mTimestamp

Definition at line 164 of file ParserOutput.php.

◆ $mTitleText

ParserOutput::$mTitleText

Definition at line 49 of file ParserOutput.php.

◆ $mTOCEnabled

ParserOutput::$mTOCEnabled = true

Definition at line 169 of file ParserOutput.php.

◆ $mTOCHTML

ParserOutput::$mTOCHTML = ''

Definition at line 159 of file ParserOutput.php.

◆ $mWarnings

ParserOutput::$mWarnings = []

Definition at line 139 of file ParserOutput.php.

◆ EDITSECTION_REGEX

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

Definition at line 211 of file ParserOutput.php.

Referenced by getText(), and MediaWiki\Tidy\RaggettWrapper\getWrapped().


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