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
{
26 * @var string $mText The output text
31 * @var array $mLanguageLinks List of the full text of language links,
32 * in the order they appear.
34 public $mLanguageLinks;
37 * @var array $mCategoriesMap of category names to sort keys
42 * @var array $mIndicators Page status indicators, usually displayed in top-right corner.
44 public $mIndicators = array();
47 * @var string $mTitleText Title text of the chosen language variant, as HTML.
52 * @var array $mLinks 2-D map of NS/DBK to ID for the links in the document.
55 public $mLinks = array();
58 * @var array $mTemplates 2-D map of NS/DBK to ID for the template references.
61 public $mTemplates = array();
64 * @var array $mTemplateIds 2-D map of NS/DBK to rev ID for the template references.
67 public $mTemplateIds = array();
70 * @var array $mImages DB keys of the images used, in the array key only
72 public $mImages = array();
75 * @var array $mFileSearchOptions DB keys of the images used mapped to sha1 and MW timestamp.
77 public $mFileSearchOptions = array();
80 * @var array $mExternalLinks External link URLs, in the key only.
82 public $mExternalLinks = array();
85 * @var array $mInterwikiLinks 2-D map of prefix/DBK (in keys only)
86 * for the inline interwiki links in the document.
88 public $mInterwikiLinks = array();
91 * @var bool $mNewSection Show a new section link?
93 public $mNewSection = false;
96 * @var bool $mHideNewSection Hide the new section link?
98 public $mHideNewSection = false;
101 * @var bool $mNoGallery No gallery on category page? (__NOGALLERY__).
103 public $mNoGallery = false;
106 * @var array $mHeadItems Items to put in the <head> section
108 public $mHeadItems = array();
111 * @var array $mModules Modules to be loaded by ResourceLoader
113 public $mModules = array();
116 * @var array $mModuleScripts Modules of which only the JS will be loaded by ResourceLoader.
118 public $mModuleScripts = array();
121 * @var array $mModuleStyles Modules of which only the CSSS will be loaded by ResourceLoader.
123 public $mModuleStyles = array();
126 * @var array $mJsConfigVars JavaScript config variable for mw.config combined with this page.
128 public $mJsConfigVars = array();
131 * @var array $mOutputHooks Hook tags as per $wgParserOutputHooks.
133 public $mOutputHooks = array();
136 * @var array $mWarnings Warning text to be returned to the user.
137 * Wikitext formatted, in the key only.
139 public $mWarnings = array();
142 * @var array $mSections Table of contents
144 public $mSections = array();
147 * @var bool $mEditSectionTokens prefix/suffix markers if edit sections were output as tokens.
149 public $mEditSectionTokens = false;
152 * @var array $mProperties Name/value pairs to be cached in the DB.
154 public $mProperties = array();
157 * @var string $mTOCHTML HTML of the TOC.
159 public $mTOCHTML = '';
162 * @var string $mTimestamp Timestamp of the revision.
167 * @var bool $mTOCEnabled Whether TOC should be shown, can't override __NOTOC__.
169 public $mTOCEnabled = true;
172 * @var bool $mEnableOOUI Whether OOUI should be enabled.
174 public $mEnableOOUI = false;
177 * @var string $mIndexPolicy 'index' or 'noindex'? Any other value will result in no change.
179 private $mIndexPolicy = '';
182 * @var array $mAccessedOptions List of ParserOptions (stored in the keys).
184 private $mAccessedOptions = array();
187 * @var array $mExtensionData extra data used by extensions.
189 private $mExtensionData = array();
192 * @var array $mLimitReportData Parser limit report data.
194 private $mLimitReportData = array();
197 * @var array $mParseStartTime Timestamps for getTimeSinceStart().
199 private $mParseStartTime = array();
202 * @var bool $mPreventClickjacking Whether to emit X-Frame-Options: DENY.
204 private $mPreventClickjacking = false;
207 * @var array $mFlags Generic flags.
209 private $mFlags = array();
211 const EDITSECTION_REGEX
=
212 '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
214 public function __construct( $text = '', $languageLinks = array(), $categoryLinks = array(),
215 $unused = false, $titletext = ''
217 $this->mText
= $text;
218 $this->mLanguageLinks
= $languageLinks;
219 $this->mCategories
= $categoryLinks;
220 $this->mTitleText
= $titletext;
224 * Get the cacheable text with <mw:editsection> markers still in it. The
225 * return value is suitable for writing back via setText() but is not valid
226 * for display to the user.
230 public function getRawText() {
234 public function getText() {
235 $text = $this->mText
;
236 if ( $this->mEditSectionTokens
) {
237 $text = preg_replace_callback(
238 ParserOutput
::EDITSECTION_REGEX
,
240 global $wgOut, $wgLang;
241 $editsectionPage = Title
::newFromText( htmlspecialchars_decode( $m[1] ) );
242 $editsectionSection = htmlspecialchars_decode( $m[2] );
243 $editsectionContent = isset( $m[4] ) ?
$m[3] : null;
245 if ( !is_object( $editsectionPage ) ) {
246 throw new MWException( "Bad parser output text." );
249 $skin = $wgOut->getSkin();
250 return call_user_func_array(
251 array( $skin, 'doEditSectionLink' ),
252 array( $editsectionPage, $editsectionSection,
253 $editsectionContent, $wgLang->getCode() )
259 $text = preg_replace( ParserOutput
::EDITSECTION_REGEX
, '', $text );
262 // If you have an old cached version of this class - sorry, you can't disable the TOC
263 if ( isset( $this->mTOCEnabled
) && $this->mTOCEnabled
) {
264 $text = str_replace( array( Parser
::TOC_START
, Parser
::TOC_END
), '', $text );
266 $text = preg_replace(
267 '#' . preg_quote( Parser
::TOC_START
, '#' ) . '.*?' . preg_quote( Parser
::TOC_END
, '#' ) . '#s',
275 public function &getLanguageLinks() {
276 return $this->mLanguageLinks
;
279 public function getInterwikiLinks() {
280 return $this->mInterwikiLinks
;
283 public function getCategoryLinks() {
284 return array_keys( $this->mCategories
);
287 public function &getCategories() {
288 return $this->mCategories
;
294 public function getIndicators() {
295 return $this->mIndicators
;
298 public function getTitleText() {
299 return $this->mTitleText
;
302 public function getSections() {
303 return $this->mSections
;
306 public function getEditSectionTokens() {
307 return $this->mEditSectionTokens
;
310 public function &getLinks() {
311 return $this->mLinks
;
314 public function &getTemplates() {
315 return $this->mTemplates
;
318 public function &getTemplateIds() {
319 return $this->mTemplateIds
;
322 public function &getImages() {
323 return $this->mImages
;
326 public function &getFileSearchOptions() {
327 return $this->mFileSearchOptions
;
330 public function &getExternalLinks() {
331 return $this->mExternalLinks
;
334 public function getNoGallery() {
335 return $this->mNoGallery
;
338 public function getHeadItems() {
339 return $this->mHeadItems
;
342 public function getModules() {
343 return $this->mModules
;
346 public function getModuleScripts() {
347 return $this->mModuleScripts
;
350 public function getModuleStyles() {
351 return $this->mModuleStyles
;
355 * @deprecated since 1.26 Obsolete
358 public function getModuleMessages() {
359 wfDeprecated( __METHOD__
, '1.26' );
364 public function getJsConfigVars() {
365 return $this->mJsConfigVars
;
368 public function getOutputHooks() {
369 return (array)$this->mOutputHooks
;
372 public function getWarnings() {
373 return array_keys( $this->mWarnings
);
376 public function getIndexPolicy() {
377 return $this->mIndexPolicy
;
380 public function getTOCHTML() {
381 return $this->mTOCHTML
;
384 public function getTimestamp() {
385 return $this->mTimestamp
;
388 public function getLimitReportData() {
389 return $this->mLimitReportData
;
392 public function getTOCEnabled() {
393 return $this->mTOCEnabled
;
396 public function getEnableOOUI() {
397 return $this->mEnableOOUI
;
400 public function setText( $text ) {
401 return wfSetVar( $this->mText
, $text );
404 public function setLanguageLinks( $ll ) {
405 return wfSetVar( $this->mLanguageLinks
, $ll );
408 public function setCategoryLinks( $cl ) {
409 return wfSetVar( $this->mCategories
, $cl );
412 public function setTitleText( $t ) {
413 return wfSetVar( $this->mTitleText
, $t );
416 public function setSections( $toc ) {
417 return wfSetVar( $this->mSections
, $toc );
420 public function setEditSectionTokens( $t ) {
421 return wfSetVar( $this->mEditSectionTokens
, $t );
424 public function setIndexPolicy( $policy ) {
425 return wfSetVar( $this->mIndexPolicy
, $policy );
428 public function setTOCHTML( $tochtml ) {
429 return wfSetVar( $this->mTOCHTML
, $tochtml );
432 public function setTimestamp( $timestamp ) {
433 return wfSetVar( $this->mTimestamp
, $timestamp );
436 public function setTOCEnabled( $flag ) {
437 return wfSetVar( $this->mTOCEnabled
, $flag );
440 public function addCategory( $c, $sort ) {
441 $this->mCategories
[$c] = $sort;
447 public function setIndicator( $id, $content ) {
448 $this->mIndicators
[$id] = $content;
452 * Enables OOUI, if true, in any OutputPage instance this ParserOutput
453 * object is added to.
456 * @param bool $enable If OOUI should be enabled or not
458 public function setEnableOOUI( $enable = false ) {
459 $this->mEnableOOUI
= $enable;
462 public function addLanguageLink( $t ) {
463 $this->mLanguageLinks
[] = $t;
466 public function addWarning( $s ) {
467 $this->mWarnings
[$s] = 1;
470 public function addOutputHook( $hook, $data = false ) {
471 $this->mOutputHooks
[] = array( $hook, $data );
474 public function setNewSection( $value ) {
475 $this->mNewSection
= (bool)$value;
477 public function hideNewSection( $value ) {
478 $this->mHideNewSection
= (bool)$value;
480 public function getHideNewSection() {
481 return (bool)$this->mHideNewSection
;
483 public function getNewSection() {
484 return (bool)$this->mNewSection
;
488 * Checks, if a url is pointing to the own server
490 * @param string $internal The server to check against
491 * @param string $url The url to check
494 public static function isLinkInternal( $internal, $url ) {
495 return (bool)preg_match( '/^' .
496 # If server is proto relative, check also for http/https links
497 ( substr( $internal, 0, 2 ) === '//' ?
'(?:https?:)?' : '' ) .
498 preg_quote( $internal, '/' ) .
499 # check for query/path/anchor or end of link in each case
505 public function addExternalLink( $url ) {
506 # We don't register links pointing to our own server, unless... :-)
507 global $wgServer, $wgRegisterInternalExternals;
509 $registerExternalLink = true;
510 if ( !$wgRegisterInternalExternals ) {
511 $registerExternalLink = !self
::isLinkInternal( $wgServer, $url );
513 if ( $registerExternalLink ) {
514 $this->mExternalLinks
[$url] = 1;
519 * Record a local or interwiki inline link for saving in future link tables.
521 * @param Title $title
522 * @param int|null $id Optional known page_id so we can skip the lookup
524 public function addLink( Title
$title, $id = null ) {
525 if ( $title->isExternal() ) {
526 // Don't record interwikis in pagelinks
527 $this->addInterwikiLink( $title );
530 $ns = $title->getNamespace();
531 $dbk = $title->getDBkey();
532 if ( $ns == NS_MEDIA
) {
533 // Normalize this pseudo-alias if it makes it down here...
535 } elseif ( $ns == NS_SPECIAL
) {
536 // We don't record Special: links currently
537 // It might actually be wise to, but we'd need to do some normalization.
539 } elseif ( $dbk === '' ) {
540 // Don't record self links - [[#Foo]]
543 if ( !isset( $this->mLinks
[$ns] ) ) {
544 $this->mLinks
[$ns] = array();
546 if ( is_null( $id ) ) {
547 $id = $title->getArticleID();
549 $this->mLinks
[$ns][$dbk] = $id;
553 * Register a file dependency for this output
554 * @param string $name Title dbKey
555 * @param string $timestamp MW timestamp of file creation (or false if non-existing)
556 * @param string $sha1 Base 36 SHA-1 of file (or false if non-existing)
559 public function addImage( $name, $timestamp = null, $sha1 = null ) {
560 $this->mImages
[$name] = 1;
561 if ( $timestamp !== null && $sha1 !== null ) {
562 $this->mFileSearchOptions
[$name] = array( 'time' => $timestamp, 'sha1' => $sha1 );
567 * Register a template dependency for this output
568 * @param Title $title
569 * @param int $page_id
573 public function addTemplate( $title, $page_id, $rev_id ) {
574 $ns = $title->getNamespace();
575 $dbk = $title->getDBkey();
576 if ( !isset( $this->mTemplates
[$ns] ) ) {
577 $this->mTemplates
[$ns] = array();
579 $this->mTemplates
[$ns][$dbk] = $page_id;
580 if ( !isset( $this->mTemplateIds
[$ns] ) ) {
581 $this->mTemplateIds
[$ns] = array();
583 $this->mTemplateIds
[$ns][$dbk] = $rev_id; // For versioning
587 * @param Title $title Title object, must be an interwiki link
588 * @throws MWException If given invalid input
590 public function addInterwikiLink( $title ) {
591 if ( !$title->isExternal() ) {
592 throw new MWException( 'Non-interwiki link passed, internal parser error.' );
594 $prefix = $title->getInterwiki();
595 if ( !isset( $this->mInterwikiLinks
[$prefix] ) ) {
596 $this->mInterwikiLinks
[$prefix] = array();
598 $this->mInterwikiLinks
[$prefix][$title->getDBkey()] = 1;
602 * Add some text to the "<head>".
603 * If $tag is set, the section with that tag will only be included once
605 * @param string $section
606 * @param string|bool $tag
608 public function addHeadItem( $section, $tag = false ) {
609 if ( $tag !== false ) {
610 $this->mHeadItems
[$tag] = $section;
612 $this->mHeadItems
[] = $section;
616 public function addModules( $modules ) {
617 $this->mModules
= array_merge( $this->mModules
, (array)$modules );
620 public function addModuleScripts( $modules ) {
621 $this->mModuleScripts
= array_merge( $this->mModuleScripts
, (array)$modules );
624 public function addModuleStyles( $modules ) {
625 $this->mModuleStyles
= array_merge( $this->mModuleStyles
, (array)$modules );
629 * @deprecated since 1.26 Use addModules() instead
630 * @param string|array $modules
632 public function addModuleMessages( $modules ) {
633 wfDeprecated( __METHOD__
, '1.26' );
637 * Add one or more variables to be set in mw.config in JavaScript.
639 * @param string|array $keys Key or array of key/value pairs.
640 * @param mixed $value [optional] Value of the configuration variable.
643 public function addJsConfigVars( $keys, $value = null ) {
644 if ( is_array( $keys ) ) {
645 foreach ( $keys as $key => $value ) {
646 $this->mJsConfigVars
[$key] = $value;
651 $this->mJsConfigVars
[$keys] = $value;
655 * Copy items from the OutputPage object into this one
657 * @param OutputPage $out
659 public function addOutputPageMetadata( OutputPage
$out ) {
660 $this->addModules( $out->getModules() );
661 $this->addModuleScripts( $out->getModuleScripts() );
662 $this->addModuleStyles( $out->getModuleStyles() );
663 $this->addJsConfigVars( $out->getJsConfigVars() );
665 $this->mHeadItems
= array_merge( $this->mHeadItems
, $out->getHeadItemsArray() );
666 $this->mPreventClickjacking
= $this->mPreventClickjacking ||
$out->getPreventClickjacking();
670 * Add a tracking category, getting the title from a system message,
671 * or print a debug message if the title is invalid.
673 * Any message used with this function should be registered so it will
674 * show up on Special:TrackingCategories. Core messages should be added
675 * to SpecialTrackingCategories::$coreTrackingCategories, and extensions
676 * should add to "TrackingCategories" in their extension.json.
678 * @param string $msg Message key
679 * @param Title $title title of the page which is being tracked
680 * @return bool Whether the addition was successful
683 public function addTrackingCategory( $msg, $title ) {
684 if ( $title->getNamespace() === NS_SPECIAL
) {
685 wfDebug( __METHOD__
. ": Not adding tracking category $msg to special page!\n" );
689 // Important to parse with correct title (bug 31469)
690 $cat = wfMessage( $msg )
692 ->inContentLanguage()
695 # Allow tracking categories to be disabled by setting them to "-"
696 if ( $cat === '-' ) {
700 $containerCategory = Title
::makeTitleSafe( NS_CATEGORY
, $cat );
701 if ( $containerCategory ) {
702 $this->addCategory( $containerCategory->getDBkey(), $this->getProperty( 'defaultsort' ) ?
: '' );
705 wfDebug( __METHOD__
. ": [[MediaWiki:$msg]] is not a valid title!\n" );
711 * Override the title to be used for display
713 * @note this is assumed to have been validated
714 * (check equal normalisation, etc.)
716 * @note this is expected to be safe HTML,
717 * ready to be served to the client.
719 * @param string $text Desired title text
721 public function setDisplayTitle( $text ) {
722 $this->setTitleText( $text );
723 $this->setProperty( 'displaytitle', $text );
727 * Get the title to be used for display.
729 * As per the contract of setDisplayTitle(), this is safe HTML,
730 * ready to be served to the client.
732 * @return string HTML
734 public function getDisplayTitle() {
735 $t = $this->getTitleText();
743 * Fairly generic flag setter thingy.
744 * @param string $flag
746 public function setFlag( $flag ) {
747 $this->mFlags
[$flag] = true;
750 public function getFlag( $flag ) {
751 return isset( $this->mFlags
[$flag] );
755 * Set a property to be stored in the page_props database table.
757 * page_props is a key value store indexed by the page ID. This allows
758 * the parser to set a property on a page which can then be quickly
759 * retrieved given the page ID or via a DB join when given the page
762 * Since 1.23, page_props are also indexed by numeric value, to allow
763 * for efficient "top k" queries of pages wrt a given property.
765 * setProperty() is thus used to propagate properties from the parsed
766 * page to request contexts other than a page view of the currently parsed
769 * Some applications examples:
771 * * To implement hidden categories, hiding pages from category listings
772 * by storing a property.
774 * * Overriding the displayed article title.
775 * @see ParserOutput::setDisplayTitle()
777 * * To implement image tagging, for example displaying an icon on an
778 * image thumbnail to indicate that it is listed for deletion on
780 * This is not actually implemented, yet but would be pretty cool.
782 * @note Do not use setProperty() to set a property which is only used
783 * in a context where the ParserOutput object itself is already available,
784 * for example a normal page view. There is no need to save such a property
785 * in the database since the text is already parsed. You can just hook
786 * OutputPageParserOutput and get your data out of the ParserOutput object.
788 * If you are writing an extension where you want to set a property in the
789 * parser which is used by an OutputPageParserOutput hook, you have to
790 * associate the extension data directly with the ParserOutput object.
791 * Since MediaWiki 1.21, you can use setExtensionData() to do this:
795 * $parser->getOutput()->setExtensionData( 'my_ext_foo', '...' );
798 * And then later, in OutputPageParserOutput or similar:
802 * $output->getExtensionData( 'my_ext_foo' );
805 * In MediaWiki 1.20 and older, you have to use a custom member variable
806 * within the ParserOutput object:
810 * $parser->getOutput()->my_ext_foo = '...';
814 public function setProperty( $name, $value ) {
815 $this->mProperties
[$name] = $value;
819 * @param string $name The property name to look up.
821 * @return mixed|bool The value previously set using setProperty(). False if null or no value
822 * was set for the given property name.
824 * @note You need to use getProperties() to check for boolean and null properties.
826 public function getProperty( $name ) {
827 return isset( $this->mProperties
[$name] ) ?
$this->mProperties
[$name] : false;
830 public function unsetProperty( $name ) {
831 unset( $this->mProperties
[$name] );
834 public function getProperties() {
835 if ( !isset( $this->mProperties
) ) {
836 $this->mProperties
= array();
838 return $this->mProperties
;
842 * Returns the options from its ParserOptions which have been taken
843 * into account to produce this output or false if not available.
846 public function getUsedOptions() {
847 if ( !isset( $this->mAccessedOptions
) ) {
850 return array_keys( $this->mAccessedOptions
);
854 * Tags a parser option for use in the cache key for this parser output.
855 * Registered as a watcher at ParserOptions::registerWatcher() by Parser::clearState().
856 * The information gathered here is available via getUsedOptions(),
857 * and is used by ParserCache::save().
859 * @see ParserCache::getKey
860 * @see ParserCache::save
861 * @see ParserOptions::addExtraKey
862 * @see ParserOptions::optionsHash
863 * @param string $option
865 public function recordOption( $option ) {
866 $this->mAccessedOptions
[$option] = true;
870 * Attaches arbitrary data to this ParserObject. This can be used to store some information in
871 * the ParserOutput object for later use during page output. The data will be cached along with
872 * the ParserOutput object, but unlike data set using setProperty(), it is not recorded in the
875 * This method is provided to overcome the unsafe practice of attaching extra information to a
876 * ParserObject by directly assigning member variables.
878 * To use setExtensionData() to pass extension information from a hook inside the parser to a
879 * hook in the page output, use this in the parser hook:
883 * $parser->getOutput()->setExtensionData( 'my_ext_foo', '...' );
886 * And then later, in OutputPageParserOutput or similar:
890 * $output->getExtensionData( 'my_ext_foo' );
893 * In MediaWiki 1.20 and older, you have to use a custom member variable
894 * within the ParserOutput object:
898 * $parser->getOutput()->my_ext_foo = '...';
903 * @param string $key The key for accessing the data. Extensions should take care to avoid
904 * conflicts in naming keys. It is suggested to use the extension's name as a prefix.
906 * @param mixed $value The value to set. Setting a value to null is equivalent to removing
909 public function setExtensionData( $key, $value ) {
910 if ( $value === null ) {
911 unset( $this->mExtensionData
[$key] );
913 $this->mExtensionData
[$key] = $value;
918 * Gets extensions data previously attached to this ParserOutput using setExtensionData().
919 * Typically, such data would be set while parsing the page, e.g. by a parser function.
923 * @param string $key The key to look up.
925 * @return mixed|null The value previously set for the given key using setExtensionData()
926 * or null if no value was set for this key.
928 public function getExtensionData( $key ) {
929 if ( isset( $this->mExtensionData
[$key] ) ) {
930 return $this->mExtensionData
[$key];
936 private static function getTimes( $clock = null ) {
938 if ( !$clock ||
$clock === 'wall' ) {
939 $ret['wall'] = microtime( true );
941 if ( !$clock ||
$clock === 'cpu' ) {
944 $ret['cpu'] = $ru['ru_utime.tv_sec'] +
$ru['ru_utime.tv_usec'] / 1e6
;
945 $ret['cpu'] +
= $ru['ru_stime.tv_sec'] +
$ru['ru_stime.tv_usec'] / 1e6
;
952 * Resets the parse start timestamps for future calls to getTimeSinceStart()
955 public function resetParseStartTime() {
956 $this->mParseStartTime
= self
::getTimes();
960 * Returns the time since resetParseStartTime() was last called
962 * Clocks available are:
963 * - wall: Wall clock time
964 * - cpu: CPU time (requires getrusage)
967 * @param string $clock
970 public function getTimeSinceStart( $clock ) {
971 if ( !isset( $this->mParseStartTime
[$clock] ) ) {
975 $end = self
::getTimes( $clock );
976 return $end[$clock] - $this->mParseStartTime
[$clock];
980 * Sets parser limit report data for a key
982 * The key is used as the prefix for various messages used for formatting:
983 * - $key: The label for the field in the limit report
984 * - $key-value-text: Message used to format the value in the "NewPP limit
985 * report" HTML comment. If missing, uses $key-format.
986 * - $key-value-html: Message used to format the value in the preview
987 * limit report table. If missing, uses $key-format.
988 * - $key-value: Message used to format the value. If missing, uses "$1".
990 * Note that all values are interpreted as wikitext, and so should be
991 * encoded with htmlspecialchars() as necessary, but should avoid complex
992 * HTML for sanity of display in the "NewPP limit report" comment.
995 * @param string $key Message key
996 * @param mixed $value Appropriate for Message::params()
998 public function setLimitReportData( $key, $value ) {
999 $this->mLimitReportData
[$key] = $value;
1003 * Check whether the cache TTL was lowered due to dynamic content
1005 * When content is determined by more than hard state (e.g. page edits),
1006 * such as template/file transclusions based on the current timestamp or
1007 * extension tags that generate lists based on queries, this return true.
1012 public function hasDynamicContent() {
1013 global $wgParserCacheExpireTime;
1015 return $this->getCacheExpiry() < $wgParserCacheExpireTime;
1019 * Get or set the prevent-clickjacking flag
1022 * @param bool|null $flag New flag value, or null to leave it unchanged
1023 * @return bool Old flag value
1025 public function preventClickjacking( $flag = null ) {
1026 return wfSetVar( $this->mPreventClickjacking
, $flag );
1030 * Save space for serialization by removing useless values
1033 public function __sleep() {
1035 array_keys( get_object_vars( $this ) ),
1036 array( 'mParseStartTime' )