4 * Output of the PHP parser.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
24 class ParserOutput
extends CacheTime
{
25 public $mText, # The output text
26 $mLanguageLinks, # List of the full text of language links, in the order they appear
27 $mCategories, # Map of category names to sort keys
28 $mIndicators = array(), # Page status indicators, usually displayed in top-right corner
29 $mTitleText, # title text of the chosen language variant
30 $mLinks = array(), # 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken.
31 $mTemplates = array(), # 2-D map of NS/DBK to ID for the template references. ID=zero for broken.
32 $mTemplateIds = array(), # 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken.
33 $mImages = array(), # DB keys of the images used, in the array key only
34 $mFileSearchOptions = array(), # DB keys of the images used mapped to sha1 and MW timestamp
35 $mExternalLinks = array(), # External link URLs, in the key only
36 $mInterwikiLinks = array(), # 2-D map of prefix/DBK (in keys only) for the inline interwiki links in the document.
37 $mNewSection = false, # Show a new section link?
38 $mHideNewSection = false, # Hide the new section link?
39 $mNoGallery = false, # No gallery on category page? (__NOGALLERY__)
40 $mHeadItems = array(), # Items to put in the <head> section
41 $mModules = array(), # Modules to be loaded by the resource loader
42 $mModuleScripts = array(), # Modules of which only the JS will be loaded by the resource loader
43 $mModuleStyles = array(), # Modules of which only the CSSS will be loaded by the resource loader
44 $mJsConfigVars = array(), # JavaScript config variable for mw.config combined with this page
45 $mOutputHooks = array(), # Hook tags as per $wgParserOutputHooks
46 $mWarnings = array(), # Warning text to be returned to the user. Wikitext formatted, in the key only
47 $mSections = array(), # Table of contents
48 $mEditSectionTokens = false, # prefix/suffix markers if edit sections were output as tokens
49 $mProperties = array(), # Name/value pairs to be cached in the DB
50 $mTOCHTML = '', # HTML of the TOC
51 $mTimestamp, # Timestamp of the revision
52 $mTOCEnabled = true, # Whether TOC should be shown, can't override __NOTOC__
53 $mEnableOOUI = false; # Whether OOUI should be enabled
54 private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change.
55 private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
56 private $mExtensionData = array(); # extra data used by extensions
57 private $mLimitReportData = array(); # Parser limit report data
58 private $mParseStartTime = array(); # Timestamps for getTimeSinceStart()
59 private $mPreventClickjacking = false; # Whether to emit X-Frame-Options: DENY
60 private $mFlags = array(); # Generic flags
62 const EDITSECTION_REGEX
=
63 '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
65 public function __construct( $text = '', $languageLinks = array(), $categoryLinks = array(),
66 $unused = false, $titletext = ''
69 $this->mLanguageLinks
= $languageLinks;
70 $this->mCategories
= $categoryLinks;
71 $this->mTitleText
= $titletext;
74 public function getText() {
76 if ( $this->mEditSectionTokens
) {
77 $text = preg_replace_callback(
78 ParserOutput
::EDITSECTION_REGEX
,
80 global $wgOut, $wgLang;
81 $editsectionPage = Title
::newFromText( htmlspecialchars_decode( $m[1] ) );
82 $editsectionSection = htmlspecialchars_decode( $m[2] );
83 $editsectionContent = isset( $m[4] ) ?
$m[3] : null;
85 if ( !is_object( $editsectionPage ) ) {
86 throw new MWException( "Bad parser output text." );
89 $skin = $wgOut->getSkin();
90 return call_user_func_array(
91 array( $skin, 'doEditSectionLink' ),
92 array( $editsectionPage, $editsectionSection,
93 $editsectionContent, $wgLang->getCode() )
99 $text = preg_replace( ParserOutput
::EDITSECTION_REGEX
, '', $text );
102 // If you have an old cached version of this class - sorry, you can't disable the TOC
103 if ( isset( $this->mTOCEnabled
) && $this->mTOCEnabled
) {
104 $text = str_replace( array( Parser
::TOC_START
, Parser
::TOC_END
), '', $text );
106 $text = preg_replace(
107 '#' . preg_quote( Parser
::TOC_START
, '#' ) . '.*?' . preg_quote( Parser
::TOC_END
, '#' ) . '#s',
115 public function &getLanguageLinks() {
116 return $this->mLanguageLinks
;
119 public function getInterwikiLinks() {
120 return $this->mInterwikiLinks
;
123 public function getCategoryLinks() {
124 return array_keys( $this->mCategories
);
127 public function &getCategories() {
128 return $this->mCategories
;
134 public function getIndicators() {
135 return $this->mIndicators
;
138 public function getTitleText() {
139 return $this->mTitleText
;
142 public function getSections() {
143 return $this->mSections
;
146 public function getEditSectionTokens() {
147 return $this->mEditSectionTokens
;
150 public function &getLinks() {
151 return $this->mLinks
;
154 public function &getTemplates() {
155 return $this->mTemplates
;
158 public function &getTemplateIds() {
159 return $this->mTemplateIds
;
162 public function &getImages() {
163 return $this->mImages
;
166 public function &getFileSearchOptions() {
167 return $this->mFileSearchOptions
;
170 public function &getExternalLinks() {
171 return $this->mExternalLinks
;
174 public function getNoGallery() {
175 return $this->mNoGallery
;
178 public function getHeadItems() {
179 return $this->mHeadItems
;
182 public function getModules() {
183 return $this->mModules
;
186 public function getModuleScripts() {
187 return $this->mModuleScripts
;
190 public function getModuleStyles() {
191 return $this->mModuleStyles
;
195 * @deprecated since 1.26 Obsolete
198 public function getModuleMessages() {
199 wfDeprecated( __METHOD__
, '1.26' );
204 public function getJsConfigVars() {
205 return $this->mJsConfigVars
;
208 public function getOutputHooks() {
209 return (array)$this->mOutputHooks
;
212 public function getWarnings() {
213 return array_keys( $this->mWarnings
);
216 public function getIndexPolicy() {
217 return $this->mIndexPolicy
;
220 public function getTOCHTML() {
221 return $this->mTOCHTML
;
224 public function getTimestamp() {
225 return $this->mTimestamp
;
228 public function getLimitReportData() {
229 return $this->mLimitReportData
;
232 public function getTOCEnabled() {
233 return $this->mTOCEnabled
;
236 public function getEnableOOUI() {
237 return $this->mEnableOOUI
;
240 public function setText( $text ) {
241 return wfSetVar( $this->mText
, $text );
244 public function setLanguageLinks( $ll ) {
245 return wfSetVar( $this->mLanguageLinks
, $ll );
248 public function setCategoryLinks( $cl ) {
249 return wfSetVar( $this->mCategories
, $cl );
252 public function setTitleText( $t ) {
253 return wfSetVar( $this->mTitleText
, $t );
256 public function setSections( $toc ) {
257 return wfSetVar( $this->mSections
, $toc );
260 public function setEditSectionTokens( $t ) {
261 return wfSetVar( $this->mEditSectionTokens
, $t );
264 public function setIndexPolicy( $policy ) {
265 return wfSetVar( $this->mIndexPolicy
, $policy );
268 public function setTOCHTML( $tochtml ) {
269 return wfSetVar( $this->mTOCHTML
, $tochtml );
272 public function setTimestamp( $timestamp ) {
273 return wfSetVar( $this->mTimestamp
, $timestamp );
276 public function setTOCEnabled( $flag ) {
277 return wfSetVar( $this->mTOCEnabled
, $flag );
280 public function addCategory( $c, $sort ) {
281 $this->mCategories
[$c] = $sort;
287 public function setIndicator( $id, $content ) {
288 $this->mIndicators
[$id] = $content;
292 * Enables OOUI, if true, in any OutputPage instance this ParserOutput
293 * object is added to.
296 * @param bool $enable If OOUI should be enabled or not
298 public function setEnableOOUI( $enable = false ) {
299 $this->mEnableOOUI
= $enable;
302 public function addLanguageLink( $t ) {
303 $this->mLanguageLinks
[] = $t;
306 public function addWarning( $s ) {
307 $this->mWarnings
[$s] = 1;
310 public function addOutputHook( $hook, $data = false ) {
311 $this->mOutputHooks
[] = array( $hook, $data );
314 public function setNewSection( $value ) {
315 $this->mNewSection
= (bool)$value;
317 public function hideNewSection( $value ) {
318 $this->mHideNewSection
= (bool)$value;
320 public function getHideNewSection() {
321 return (bool)$this->mHideNewSection
;
323 public function getNewSection() {
324 return (bool)$this->mNewSection
;
328 * Checks, if a url is pointing to the own server
330 * @param string $internal The server to check against
331 * @param string $url The url to check
334 public static function isLinkInternal( $internal, $url ) {
335 return (bool)preg_match( '/^' .
336 # If server is proto relative, check also for http/https links
337 ( substr( $internal, 0, 2 ) === '//' ?
'(?:https?:)?' : '' ) .
338 preg_quote( $internal, '/' ) .
339 # check for query/path/anchor or end of link in each case
345 public function addExternalLink( $url ) {
346 # We don't register links pointing to our own server, unless... :-)
347 global $wgServer, $wgRegisterInternalExternals;
349 $registerExternalLink = true;
350 if ( !$wgRegisterInternalExternals ) {
351 $registerExternalLink = !self
::isLinkInternal( $wgServer, $url );
353 if ( $registerExternalLink ) {
354 $this->mExternalLinks
[$url] = 1;
359 * Record a local or interwiki inline link for saving in future link tables.
361 * @param Title $title
362 * @param int|null $id Optional known page_id so we can skip the lookup
364 public function addLink( Title
$title, $id = null ) {
365 if ( $title->isExternal() ) {
366 // Don't record interwikis in pagelinks
367 $this->addInterwikiLink( $title );
370 $ns = $title->getNamespace();
371 $dbk = $title->getDBkey();
372 if ( $ns == NS_MEDIA
) {
373 // Normalize this pseudo-alias if it makes it down here...
375 } elseif ( $ns == NS_SPECIAL
) {
376 // We don't record Special: links currently
377 // It might actually be wise to, but we'd need to do some normalization.
379 } elseif ( $dbk === '' ) {
380 // Don't record self links - [[#Foo]]
383 if ( !isset( $this->mLinks
[$ns] ) ) {
384 $this->mLinks
[$ns] = array();
386 if ( is_null( $id ) ) {
387 $id = $title->getArticleID();
389 $this->mLinks
[$ns][$dbk] = $id;
393 * Register a file dependency for this output
394 * @param string $name Title dbKey
395 * @param string $timestamp MW timestamp of file creation (or false if non-existing)
396 * @param string $sha1 Base 36 SHA-1 of file (or false if non-existing)
399 public function addImage( $name, $timestamp = null, $sha1 = null ) {
400 $this->mImages
[$name] = 1;
401 if ( $timestamp !== null && $sha1 !== null ) {
402 $this->mFileSearchOptions
[$name] = array( 'time' => $timestamp, 'sha1' => $sha1 );
407 * Register a template dependency for this output
408 * @param Title $title
409 * @param int $page_id
413 public function addTemplate( $title, $page_id, $rev_id ) {
414 $ns = $title->getNamespace();
415 $dbk = $title->getDBkey();
416 if ( !isset( $this->mTemplates
[$ns] ) ) {
417 $this->mTemplates
[$ns] = array();
419 $this->mTemplates
[$ns][$dbk] = $page_id;
420 if ( !isset( $this->mTemplateIds
[$ns] ) ) {
421 $this->mTemplateIds
[$ns] = array();
423 $this->mTemplateIds
[$ns][$dbk] = $rev_id; // For versioning
427 * @param Title $title Title object, must be an interwiki link
428 * @throws MWException If given invalid input
430 public function addInterwikiLink( $title ) {
431 if ( !$title->isExternal() ) {
432 throw new MWException( 'Non-interwiki link passed, internal parser error.' );
434 $prefix = $title->getInterwiki();
435 if ( !isset( $this->mInterwikiLinks
[$prefix] ) ) {
436 $this->mInterwikiLinks
[$prefix] = array();
438 $this->mInterwikiLinks
[$prefix][$title->getDBkey()] = 1;
442 * Add some text to the "<head>".
443 * If $tag is set, the section with that tag will only be included once
445 * @param string $section
446 * @param string|bool $tag
448 public function addHeadItem( $section, $tag = false ) {
449 if ( $tag !== false ) {
450 $this->mHeadItems
[$tag] = $section;
452 $this->mHeadItems
[] = $section;
456 public function addModules( $modules ) {
457 $this->mModules
= array_merge( $this->mModules
, (array)$modules );
460 public function addModuleScripts( $modules ) {
461 $this->mModuleScripts
= array_merge( $this->mModuleScripts
, (array)$modules );
464 public function addModuleStyles( $modules ) {
465 $this->mModuleStyles
= array_merge( $this->mModuleStyles
, (array)$modules );
469 * @deprecated since 1.26 Use addModules() instead
470 * @param string|array $modules
472 public function addModuleMessages( $modules ) {
473 wfDeprecated( __METHOD__
, '1.26' );
477 * Add one or more variables to be set in mw.config in JavaScript.
479 * @param string|array $keys Key or array of key/value pairs.
480 * @param mixed $value [optional] Value of the configuration variable.
483 public function addJsConfigVars( $keys, $value = null ) {
484 if ( is_array( $keys ) ) {
485 foreach ( $keys as $key => $value ) {
486 $this->mJsConfigVars
[$key] = $value;
491 $this->mJsConfigVars
[$keys] = $value;
495 * Copy items from the OutputPage object into this one
497 * @param OutputPage $out
499 public function addOutputPageMetadata( OutputPage
$out ) {
500 $this->addModules( $out->getModules() );
501 $this->addModuleScripts( $out->getModuleScripts() );
502 $this->addModuleStyles( $out->getModuleStyles() );
503 $this->addJsConfigVars( $out->getJsConfigVars() );
505 $this->mHeadItems
= array_merge( $this->mHeadItems
, $out->getHeadItemsArray() );
506 $this->mPreventClickjacking
= $this->mPreventClickjacking ||
$out->getPreventClickjacking();
510 * Add a tracking category, getting the title from a system message,
511 * or print a debug message if the title is invalid.
513 * Any message used with this function should be registered so it will
514 * show up on Special:TrackingCategories. Core messages should be added
515 * to SpecialTrackingCategories::$coreTrackingCategories, and extensions
516 * should add to "TrackingCategories" in their extension.json.
518 * @param string $msg Message key
519 * @param Title $title title of the page which is being tracked
520 * @return bool Whether the addition was successful
523 public function addTrackingCategory( $msg, $title ) {
524 if ( $title->getNamespace() === NS_SPECIAL
) {
525 wfDebug( __METHOD__
. ": Not adding tracking category $msg to special page!\n" );
529 // Important to parse with correct title (bug 31469)
530 $cat = wfMessage( $msg )
532 ->inContentLanguage()
535 # Allow tracking categories to be disabled by setting them to "-"
536 if ( $cat === '-' ) {
540 $containerCategory = Title
::makeTitleSafe( NS_CATEGORY
, $cat );
541 if ( $containerCategory ) {
542 $this->addCategory( $containerCategory->getDBkey(), $this->getProperty( 'defaultsort' ) ?
: '' );
545 wfDebug( __METHOD__
. ": [[MediaWiki:$msg]] is not a valid title!\n" );
551 * Override the title to be used for display
552 * -- this is assumed to have been validated
553 * (check equal normalisation, etc.)
555 * @param string $text Desired title text
557 public function setDisplayTitle( $text ) {
558 $this->setTitleText( $text );
559 $this->setProperty( 'displaytitle', $text );
563 * Get the title to be used for display
567 public function getDisplayTitle() {
568 $t = $this->getTitleText();
576 * Fairly generic flag setter thingy.
577 * @param string $flag
579 public function setFlag( $flag ) {
580 $this->mFlags
[$flag] = true;
583 public function getFlag( $flag ) {
584 return isset( $this->mFlags
[$flag] );
588 * Set a property to be stored in the page_props database table.
590 * page_props is a key value store indexed by the page ID. This allows
591 * the parser to set a property on a page which can then be quickly
592 * retrieved given the page ID or via a DB join when given the page
595 * Since 1.23, page_props are also indexed by numeric value, to allow
596 * for efficient "top k" queries of pages wrt a given property.
598 * setProperty() is thus used to propagate properties from the parsed
599 * page to request contexts other than a page view of the currently parsed
602 * Some applications examples:
604 * * To implement hidden categories, hiding pages from category listings
605 * by storing a property.
607 * * Overriding the displayed article title.
608 * @see ParserOutput::setDisplayTitle()
610 * * To implement image tagging, for example displaying an icon on an
611 * image thumbnail to indicate that it is listed for deletion on
613 * This is not actually implemented, yet but would be pretty cool.
615 * @note Do not use setProperty() to set a property which is only used
616 * in a context where the ParserOutput object itself is already available,
617 * for example a normal page view. There is no need to save such a property
618 * in the database since the text is already parsed. You can just hook
619 * OutputPageParserOutput and get your data out of the ParserOutput object.
621 * If you are writing an extension where you want to set a property in the
622 * parser which is used by an OutputPageParserOutput hook, you have to
623 * associate the extension data directly with the ParserOutput object.
624 * Since MediaWiki 1.21, you can use setExtensionData() to do this:
628 * $parser->getOutput()->setExtensionData( 'my_ext_foo', '...' );
631 * And then later, in OutputPageParserOutput or similar:
635 * $output->getExtensionData( 'my_ext_foo' );
638 * In MediaWiki 1.20 and older, you have to use a custom member variable
639 * within the ParserOutput object:
643 * $parser->getOutput()->my_ext_foo = '...';
647 public function setProperty( $name, $value ) {
648 $this->mProperties
[$name] = $value;
652 * @param string $name The property name to look up.
654 * @return mixed|bool The value previously set using setProperty(). False if null or no value
655 * was set for the given property name.
657 * @note You need to use getProperties() to check for boolean and null properties.
659 public function getProperty( $name ) {
660 return isset( $this->mProperties
[$name] ) ?
$this->mProperties
[$name] : false;
663 public function unsetProperty( $name ) {
664 unset( $this->mProperties
[$name] );
667 public function getProperties() {
668 if ( !isset( $this->mProperties
) ) {
669 $this->mProperties
= array();
671 return $this->mProperties
;
675 * Returns the options from its ParserOptions which have been taken
676 * into account to produce this output or false if not available.
679 public function getUsedOptions() {
680 if ( !isset( $this->mAccessedOptions
) ) {
683 return array_keys( $this->mAccessedOptions
);
687 * Tags a parser option for use in the cache key for this parser output.
688 * Registered as a watcher at ParserOptions::registerWatcher() by Parser::clearState().
690 * @see ParserCache::getKey
691 * @see ParserCache::save
692 * @see ParserOptions::addExtraKey
693 * @see ParserOptions::optionsHash
694 * @param string $option
696 public function recordOption( $option ) {
697 $this->mAccessedOptions
[$option] = true;
701 * @deprecated since 1.25. Instead, store any relevant data using setExtensionData,
702 * and implement Content::getSecondaryDataUpdates() if possible, or use the
703 * 'SecondaryDataUpdates' hook to construct the necessary update objects.
705 * @note Hard deprecation and removal without long deprecation period, since there are no
706 * known users, but known conceptual issues.
708 * @todo remove in 1.26
710 * @param DataUpdate $update
712 * @throws MWException
714 public function addSecondaryDataUpdate( DataUpdate
$update ) {
715 wfDeprecated( __METHOD__
, '1.25' );
716 throw new MWException( 'ParserOutput::addSecondaryDataUpdate() is no longer supported. Override Content::getSecondaryDataUpdates() or use the SecondaryDataUpdates hook instead.' );
720 * @deprecated since 1.25.
722 * @note Hard deprecation and removal without long deprecation period, since there are no
723 * known users, but known conceptual issues.
725 * @todo remove in 1.26
727 * @return bool false (since 1.25)
729 public function hasCustomDataUpdates() {
730 wfDeprecated( __METHOD__
, '1.25' );
735 * @deprecated since 1.25. Instead, store any relevant data using setExtensionData,
736 * and implement Content::getSecondaryDataUpdates() if possible, or use the
737 * 'SecondaryDataUpdates' hook to construct the necessary update objects.
739 * @note Hard deprecation and removal without long deprecation period, since there are no
740 * known users, but known conceptual issues.
742 * @todo remove in 1.26
744 * @param Title $title
745 * @param bool $recursive
747 * @return array An array of instances of DataUpdate
749 public function getSecondaryDataUpdates( Title
$title = null, $recursive = true ) {
750 wfDeprecated( __METHOD__
, '1.25' );
755 * Attaches arbitrary data to this ParserObject. This can be used to store some information in
756 * the ParserOutput object for later use during page output. The data will be cached along with
757 * the ParserOutput object, but unlike data set using setProperty(), it is not recorded in the
760 * This method is provided to overcome the unsafe practice of attaching extra information to a
761 * ParserObject by directly assigning member variables.
763 * To use setExtensionData() to pass extension information from a hook inside the parser to a
764 * hook in the page output, use this in the parser hook:
768 * $parser->getOutput()->setExtensionData( 'my_ext_foo', '...' );
771 * And then later, in OutputPageParserOutput or similar:
775 * $output->getExtensionData( 'my_ext_foo' );
778 * In MediaWiki 1.20 and older, you have to use a custom member variable
779 * within the ParserOutput object:
783 * $parser->getOutput()->my_ext_foo = '...';
788 * @param string $key The key for accessing the data. Extensions should take care to avoid
789 * conflicts in naming keys. It is suggested to use the extension's name as a prefix.
791 * @param mixed $value The value to set. Setting a value to null is equivalent to removing
794 public function setExtensionData( $key, $value ) {
795 if ( $value === null ) {
796 unset( $this->mExtensionData
[$key] );
798 $this->mExtensionData
[$key] = $value;
803 * Gets extensions data previously attached to this ParserOutput using setExtensionData().
804 * Typically, such data would be set while parsing the page, e.g. by a parser function.
808 * @param string $key The key to look up.
810 * @return mixed|null The value previously set for the given key using setExtensionData()
811 * or null if no value was set for this key.
813 public function getExtensionData( $key ) {
814 if ( isset( $this->mExtensionData
[$key] ) ) {
815 return $this->mExtensionData
[$key];
821 private static function getTimes( $clock = null ) {
823 if ( !$clock ||
$clock === 'wall' ) {
824 $ret['wall'] = microtime( true );
826 if ( !$clock ||
$clock === 'cpu' ) {
829 $ret['cpu'] = $ru['ru_utime.tv_sec'] +
$ru['ru_utime.tv_usec'] / 1e6
;
830 $ret['cpu'] +
= $ru['ru_stime.tv_sec'] +
$ru['ru_stime.tv_usec'] / 1e6
;
837 * Resets the parse start timestamps for future calls to getTimeSinceStart()
840 public function resetParseStartTime() {
841 $this->mParseStartTime
= self
::getTimes();
845 * Returns the time since resetParseStartTime() was last called
847 * Clocks available are:
848 * - wall: Wall clock time
849 * - cpu: CPU time (requires getrusage)
852 * @param string $clock
855 public function getTimeSinceStart( $clock ) {
856 if ( !isset( $this->mParseStartTime
[$clock] ) ) {
860 $end = self
::getTimes( $clock );
861 return $end[$clock] - $this->mParseStartTime
[$clock];
865 * Sets parser limit report data for a key
867 * The key is used as the prefix for various messages used for formatting:
868 * - $key: The label for the field in the limit report
869 * - $key-value-text: Message used to format the value in the "NewPP limit
870 * report" HTML comment. If missing, uses $key-format.
871 * - $key-value-html: Message used to format the value in the preview
872 * limit report table. If missing, uses $key-format.
873 * - $key-value: Message used to format the value. If missing, uses "$1".
875 * Note that all values are interpreted as wikitext, and so should be
876 * encoded with htmlspecialchars() as necessary, but should avoid complex
877 * HTML for sanity of display in the "NewPP limit report" comment.
880 * @param string $key Message key
881 * @param mixed $value Appropriate for Message::params()
883 public function setLimitReportData( $key, $value ) {
884 $this->mLimitReportData
[$key] = $value;
888 * Check whether the cache TTL was lowered due to dynamic content
890 * When content is determined by more than hard state (e.g. page edits),
891 * such as template/file transclusions based on the current timestamp or
892 * extension tags that generate lists based on queries, this return true.
897 public function hasDynamicContent() {
898 global $wgParserCacheExpireTime;
900 return $this->getCacheExpiry() < $wgParserCacheExpireTime;
904 * Get or set the prevent-clickjacking flag
907 * @param bool|null $flag New flag value, or null to leave it unchanged
908 * @return bool Old flag value
910 public function preventClickjacking( $flag = null ) {
911 return wfSetVar( $this->mPreventClickjacking
, $flag );
915 * Save space for serialization by removing useless values
918 public function __sleep() {
920 array_keys( get_object_vars( $this ) ),
921 array( 'mParseStartTime' )