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 = [];
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.
58 * @var array $mTemplates 2-D map of NS/DBK to ID for the template references.
61 public $mTemplates = [];
64 * @var array $mTemplateIds 2-D map of NS/DBK to rev ID for the template references.
67 public $mTemplateIds = [];
70 * @var array $mImages DB keys of the images used, in the array key only
75 * @var array $mFileSearchOptions DB keys of the images used mapped to sha1 and MW timestamp.
77 public $mFileSearchOptions = [];
80 * @var array $mExternalLinks External link URLs, in the key only.
82 public $mExternalLinks = [];
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 = [];
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 = [];
111 * @var array $mModules Modules to be loaded by ResourceLoader
113 public $mModules = [];
116 * @var array $mModuleScripts Modules of which only the JS will be loaded by ResourceLoader.
118 public $mModuleScripts = [];
121 * @var array $mModuleStyles Modules of which only the CSSS will be loaded by ResourceLoader.
123 public $mModuleStyles = [];
126 * @var array $mJsConfigVars JavaScript config variable for mw.config combined with this page.
128 public $mJsConfigVars = [];
131 * @var array $mOutputHooks Hook tags as per $wgParserOutputHooks.
133 public $mOutputHooks = [];
136 * @var array $mWarnings Warning text to be returned to the user.
137 * Wikitext formatted, in the key only.
139 public $mWarnings = [];
142 * @var array $mSections Table of contents
144 public $mSections = [];
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 = [];
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 = [];
187 * @var array $mExtensionData extra data used by extensions.
189 private $mExtensionData = [];
192 * @var array $mLimitReportData Parser limit report data.
194 private $mLimitReportData = [];
197 * @var array $mParseStartTime Timestamps for getTimeSinceStart().
199 private $mParseStartTime = [];
202 * @var bool $mPreventClickjacking Whether to emit X-Frame-Options: DENY.
204 private $mPreventClickjacking = false;
207 * @var array $mFlags Generic flags.
209 private $mFlags = [];
211 /** @var integer|null Assumed rev ID for {{REVISIONID}} if no revision is set */
212 private $mSpeculativeRevId;
214 const EDITSECTION_REGEX
=
215 '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
217 public function __construct( $text = '', $languageLinks = [], $categoryLinks = [],
218 $unused = false, $titletext = ''
220 $this->mText
= $text;
221 $this->mLanguageLinks
= $languageLinks;
222 $this->mCategories
= $categoryLinks;
223 $this->mTitleText
= $titletext;
227 * Get the cacheable text with <mw:editsection> markers still in it. The
228 * return value is suitable for writing back via setText() but is not valid
229 * for display to the user.
233 public function getRawText() {
237 public function getText() {
238 $text = $this->mText
;
239 if ( $this->mEditSectionTokens
) {
240 $text = preg_replace_callback(
241 ParserOutput
::EDITSECTION_REGEX
,
243 global $wgOut, $wgLang;
244 $editsectionPage = Title
::newFromText( htmlspecialchars_decode( $m[1] ) );
245 $editsectionSection = htmlspecialchars_decode( $m[2] );
246 $editsectionContent = isset( $m[4] ) ?
$m[3] : null;
248 if ( !is_object( $editsectionPage ) ) {
249 throw new MWException( "Bad parser output text." );
252 $skin = $wgOut->getSkin();
253 return call_user_func_array(
254 [ $skin, 'doEditSectionLink' ],
255 [ $editsectionPage, $editsectionSection,
256 $editsectionContent, $wgLang->getCode() ]
262 $text = preg_replace( ParserOutput
::EDITSECTION_REGEX
, '', $text );
265 // If you have an old cached version of this class - sorry, you can't disable the TOC
266 if ( isset( $this->mTOCEnabled
) && $this->mTOCEnabled
) {
267 $text = str_replace( [ Parser
::TOC_START
, Parser
::TOC_END
], '', $text );
269 $text = preg_replace(
270 '#' . preg_quote( Parser
::TOC_START
, '#' ) . '.*?' . preg_quote( Parser
::TOC_END
, '#' ) . '#s',
282 public function setSpeculativeRevIdUsed( $id ) {
283 $this->mSpeculativeRevId
= $id;
287 public function getSpeculativeRevIdUsed() {
288 return $this->mSpeculativeRevId
;
291 public function &getLanguageLinks() {
292 return $this->mLanguageLinks
;
295 public function getInterwikiLinks() {
296 return $this->mInterwikiLinks
;
299 public function getCategoryLinks() {
300 return array_keys( $this->mCategories
);
303 public function &getCategories() {
304 return $this->mCategories
;
310 public function getIndicators() {
311 return $this->mIndicators
;
314 public function getTitleText() {
315 return $this->mTitleText
;
318 public function getSections() {
319 return $this->mSections
;
322 public function getEditSectionTokens() {
323 return $this->mEditSectionTokens
;
326 public function &getLinks() {
327 return $this->mLinks
;
330 public function &getTemplates() {
331 return $this->mTemplates
;
334 public function &getTemplateIds() {
335 return $this->mTemplateIds
;
338 public function &getImages() {
339 return $this->mImages
;
342 public function &getFileSearchOptions() {
343 return $this->mFileSearchOptions
;
346 public function &getExternalLinks() {
347 return $this->mExternalLinks
;
350 public function getNoGallery() {
351 return $this->mNoGallery
;
354 public function getHeadItems() {
355 return $this->mHeadItems
;
358 public function getModules() {
359 return $this->mModules
;
362 public function getModuleScripts() {
363 return $this->mModuleScripts
;
366 public function getModuleStyles() {
367 return $this->mModuleStyles
;
371 public function getJsConfigVars() {
372 return $this->mJsConfigVars
;
375 public function getOutputHooks() {
376 return (array)$this->mOutputHooks
;
379 public function getWarnings() {
380 return array_keys( $this->mWarnings
);
383 public function getIndexPolicy() {
384 return $this->mIndexPolicy
;
387 public function getTOCHTML() {
388 return $this->mTOCHTML
;
392 * @return string|null TS_MW timestamp of the revision content
394 public function getTimestamp() {
395 return $this->mTimestamp
;
398 public function getLimitReportData() {
399 return $this->mLimitReportData
;
402 public function getTOCEnabled() {
403 return $this->mTOCEnabled
;
406 public function getEnableOOUI() {
407 return $this->mEnableOOUI
;
410 public function setText( $text ) {
411 return wfSetVar( $this->mText
, $text );
414 public function setLanguageLinks( $ll ) {
415 return wfSetVar( $this->mLanguageLinks
, $ll );
418 public function setCategoryLinks( $cl ) {
419 return wfSetVar( $this->mCategories
, $cl );
422 public function setTitleText( $t ) {
423 return wfSetVar( $this->mTitleText
, $t );
426 public function setSections( $toc ) {
427 return wfSetVar( $this->mSections
, $toc );
430 public function setEditSectionTokens( $t ) {
431 return wfSetVar( $this->mEditSectionTokens
, $t );
434 public function setIndexPolicy( $policy ) {
435 return wfSetVar( $this->mIndexPolicy
, $policy );
438 public function setTOCHTML( $tochtml ) {
439 return wfSetVar( $this->mTOCHTML
, $tochtml );
442 public function setTimestamp( $timestamp ) {
443 return wfSetVar( $this->mTimestamp
, $timestamp );
446 public function setTOCEnabled( $flag ) {
447 return wfSetVar( $this->mTOCEnabled
, $flag );
450 public function addCategory( $c, $sort ) {
451 $this->mCategories
[$c] = $sort;
457 public function setIndicator( $id, $content ) {
458 $this->mIndicators
[$id] = $content;
462 * Enables OOUI, if true, in any OutputPage instance this ParserOutput
463 * object is added to.
466 * @param bool $enable If OOUI should be enabled or not
468 public function setEnableOOUI( $enable = false ) {
469 $this->mEnableOOUI
= $enable;
472 public function addLanguageLink( $t ) {
473 $this->mLanguageLinks
[] = $t;
476 public function addWarning( $s ) {
477 $this->mWarnings
[$s] = 1;
480 public function addOutputHook( $hook, $data = false ) {
481 $this->mOutputHooks
[] = [ $hook, $data ];
484 public function setNewSection( $value ) {
485 $this->mNewSection
= (bool)$value;
487 public function hideNewSection( $value ) {
488 $this->mHideNewSection
= (bool)$value;
490 public function getHideNewSection() {
491 return (bool)$this->mHideNewSection
;
493 public function getNewSection() {
494 return (bool)$this->mNewSection
;
498 * Checks, if a url is pointing to the own server
500 * @param string $internal The server to check against
501 * @param string $url The url to check
504 public static function isLinkInternal( $internal, $url ) {
505 return (bool)preg_match( '/^' .
506 # If server is proto relative, check also for http/https links
507 ( substr( $internal, 0, 2 ) === '//' ?
'(?:https?:)?' : '' ) .
508 preg_quote( $internal, '/' ) .
509 # check for query/path/anchor or end of link in each case
515 public function addExternalLink( $url ) {
516 # We don't register links pointing to our own server, unless... :-)
517 global $wgServer, $wgRegisterInternalExternals;
519 $registerExternalLink = true;
520 if ( !$wgRegisterInternalExternals ) {
521 $registerExternalLink = !self
::isLinkInternal( $wgServer, $url );
523 if ( $registerExternalLink ) {
524 $this->mExternalLinks
[$url] = 1;
529 * Record a local or interwiki inline link for saving in future link tables.
531 * @param Title $title
532 * @param int|null $id Optional known page_id so we can skip the lookup
534 public function addLink( Title
$title, $id = null ) {
535 if ( $title->isExternal() ) {
536 // Don't record interwikis in pagelinks
537 $this->addInterwikiLink( $title );
540 $ns = $title->getNamespace();
541 $dbk = $title->getDBkey();
542 if ( $ns == NS_MEDIA
) {
543 // Normalize this pseudo-alias if it makes it down here...
545 } elseif ( $ns == NS_SPECIAL
) {
546 // We don't record Special: links currently
547 // It might actually be wise to, but we'd need to do some normalization.
549 } elseif ( $dbk === '' ) {
550 // Don't record self links - [[#Foo]]
553 if ( !isset( $this->mLinks
[$ns] ) ) {
554 $this->mLinks
[$ns] = [];
556 if ( is_null( $id ) ) {
557 $id = $title->getArticleID();
559 $this->mLinks
[$ns][$dbk] = $id;
563 * Register a file dependency for this output
564 * @param string $name Title dbKey
565 * @param string $timestamp MW timestamp of file creation (or false if non-existing)
566 * @param string $sha1 Base 36 SHA-1 of file (or false if non-existing)
569 public function addImage( $name, $timestamp = null, $sha1 = null ) {
570 $this->mImages
[$name] = 1;
571 if ( $timestamp !== null && $sha1 !== null ) {
572 $this->mFileSearchOptions
[$name] = [ 'time' => $timestamp, 'sha1' => $sha1 ];
577 * Register a template dependency for this output
578 * @param Title $title
579 * @param int $page_id
583 public function addTemplate( $title, $page_id, $rev_id ) {
584 $ns = $title->getNamespace();
585 $dbk = $title->getDBkey();
586 if ( !isset( $this->mTemplates
[$ns] ) ) {
587 $this->mTemplates
[$ns] = [];
589 $this->mTemplates
[$ns][$dbk] = $page_id;
590 if ( !isset( $this->mTemplateIds
[$ns] ) ) {
591 $this->mTemplateIds
[$ns] = [];
593 $this->mTemplateIds
[$ns][$dbk] = $rev_id; // For versioning
597 * @param Title $title Title object, must be an interwiki link
598 * @throws MWException If given invalid input
600 public function addInterwikiLink( $title ) {
601 if ( !$title->isExternal() ) {
602 throw new MWException( 'Non-interwiki link passed, internal parser error.' );
604 $prefix = $title->getInterwiki();
605 if ( !isset( $this->mInterwikiLinks
[$prefix] ) ) {
606 $this->mInterwikiLinks
[$prefix] = [];
608 $this->mInterwikiLinks
[$prefix][$title->getDBkey()] = 1;
612 * Add some text to the "<head>".
613 * If $tag is set, the section with that tag will only be included once
615 * @param string $section
616 * @param string|bool $tag
618 public function addHeadItem( $section, $tag = false ) {
619 if ( $tag !== false ) {
620 $this->mHeadItems
[$tag] = $section;
622 $this->mHeadItems
[] = $section;
626 public function addModules( $modules ) {
627 $this->mModules
= array_merge( $this->mModules
, (array)$modules );
630 public function addModuleScripts( $modules ) {
631 $this->mModuleScripts
= array_merge( $this->mModuleScripts
, (array)$modules );
634 public function addModuleStyles( $modules ) {
635 $this->mModuleStyles
= array_merge( $this->mModuleStyles
, (array)$modules );
639 * Add one or more variables to be set in mw.config in JavaScript.
641 * @param string|array $keys Key or array of key/value pairs.
642 * @param mixed $value [optional] Value of the configuration variable.
645 public function addJsConfigVars( $keys, $value = null ) {
646 if ( is_array( $keys ) ) {
647 foreach ( $keys as $key => $value ) {
648 $this->mJsConfigVars
[$key] = $value;
653 $this->mJsConfigVars
[$keys] = $value;
657 * Copy items from the OutputPage object into this one
659 * @param OutputPage $out
661 public function addOutputPageMetadata( OutputPage
$out ) {
662 $this->addModules( $out->getModules() );
663 $this->addModuleScripts( $out->getModuleScripts() );
664 $this->addModuleStyles( $out->getModuleStyles() );
665 $this->addJsConfigVars( $out->getJsConfigVars() );
667 $this->mHeadItems
= array_merge( $this->mHeadItems
, $out->getHeadItemsArray() );
668 $this->mPreventClickjacking
= $this->mPreventClickjacking ||
$out->getPreventClickjacking();
672 * Add a tracking category, getting the title from a system message,
673 * or print a debug message if the title is invalid.
675 * Any message used with this function should be registered so it will
676 * show up on Special:TrackingCategories. Core messages should be added
677 * to SpecialTrackingCategories::$coreTrackingCategories, and extensions
678 * should add to "TrackingCategories" in their extension.json.
680 * @param string $msg Message key
681 * @param Title $title title of the page which is being tracked
682 * @return bool Whether the addition was successful
685 public function addTrackingCategory( $msg, $title ) {
686 if ( $title->getNamespace() === NS_SPECIAL
) {
687 wfDebug( __METHOD__
. ": Not adding tracking category $msg to special page!\n" );
691 // Important to parse with correct title (bug 31469)
692 $cat = wfMessage( $msg )
694 ->inContentLanguage()
697 # Allow tracking categories to be disabled by setting them to "-"
698 if ( $cat === '-' ) {
702 $containerCategory = Title
::makeTitleSafe( NS_CATEGORY
, $cat );
703 if ( $containerCategory ) {
704 $this->addCategory( $containerCategory->getDBkey(), $this->getProperty( 'defaultsort' ) ?
: '' );
707 wfDebug( __METHOD__
. ": [[MediaWiki:$msg]] is not a valid title!\n" );
713 * Override the title to be used for display
715 * @note this is assumed to have been validated
716 * (check equal normalisation, etc.)
718 * @note this is expected to be safe HTML,
719 * ready to be served to the client.
721 * @param string $text Desired title text
723 public function setDisplayTitle( $text ) {
724 $this->setTitleText( $text );
725 $this->setProperty( 'displaytitle', $text );
729 * Get the title to be used for display.
731 * As per the contract of setDisplayTitle(), this is safe HTML,
732 * ready to be served to the client.
734 * @return string HTML
736 public function getDisplayTitle() {
737 $t = $this->getTitleText();
745 * Fairly generic flag setter thingy.
746 * @param string $flag
748 public function setFlag( $flag ) {
749 $this->mFlags
[$flag] = true;
752 public function getFlag( $flag ) {
753 return isset( $this->mFlags
[$flag] );
757 * Set a property to be stored in the page_props database table.
759 * page_props is a key value store indexed by the page ID. This allows
760 * the parser to set a property on a page which can then be quickly
761 * retrieved given the page ID or via a DB join when given the page
764 * Since 1.23, page_props are also indexed by numeric value, to allow
765 * for efficient "top k" queries of pages wrt a given property.
767 * setProperty() is thus used to propagate properties from the parsed
768 * page to request contexts other than a page view of the currently parsed
771 * Some applications examples:
773 * * To implement hidden categories, hiding pages from category listings
774 * by storing a property.
776 * * Overriding the displayed article title.
777 * @see ParserOutput::setDisplayTitle()
779 * * To implement image tagging, for example displaying an icon on an
780 * image thumbnail to indicate that it is listed for deletion on
782 * This is not actually implemented, yet but would be pretty cool.
784 * @note Do not use setProperty() to set a property which is only used
785 * in a context where the ParserOutput object itself is already available,
786 * for example a normal page view. There is no need to save such a property
787 * in the database since the text is already parsed. You can just hook
788 * OutputPageParserOutput and get your data out of the ParserOutput object.
790 * If you are writing an extension where you want to set a property in the
791 * parser which is used by an OutputPageParserOutput hook, you have to
792 * associate the extension data directly with the ParserOutput object.
793 * Since MediaWiki 1.21, you can use setExtensionData() to do this:
797 * $parser->getOutput()->setExtensionData( 'my_ext_foo', '...' );
800 * And then later, in OutputPageParserOutput or similar:
804 * $output->getExtensionData( 'my_ext_foo' );
807 * In MediaWiki 1.20 and older, you have to use a custom member variable
808 * within the ParserOutput object:
812 * $parser->getOutput()->my_ext_foo = '...';
816 public function setProperty( $name, $value ) {
817 $this->mProperties
[$name] = $value;
821 * @param string $name The property name to look up.
823 * @return mixed|bool The value previously set using setProperty(). False if null or no value
824 * was set for the given property name.
826 * @note You need to use getProperties() to check for boolean and null properties.
828 public function getProperty( $name ) {
829 return isset( $this->mProperties
[$name] ) ?
$this->mProperties
[$name] : false;
832 public function unsetProperty( $name ) {
833 unset( $this->mProperties
[$name] );
836 public function getProperties() {
837 if ( !isset( $this->mProperties
) ) {
838 $this->mProperties
= [];
840 return $this->mProperties
;
844 * Returns the options from its ParserOptions which have been taken
845 * into account to produce this output or false if not available.
848 public function getUsedOptions() {
849 if ( !isset( $this->mAccessedOptions
) ) {
852 return array_keys( $this->mAccessedOptions
);
856 * Tags a parser option for use in the cache key for this parser output.
857 * Registered as a watcher at ParserOptions::registerWatcher() by Parser::clearState().
858 * The information gathered here is available via getUsedOptions(),
859 * and is used by ParserCache::save().
861 * @see ParserCache::getKey
862 * @see ParserCache::save
863 * @see ParserOptions::addExtraKey
864 * @see ParserOptions::optionsHash
865 * @param string $option
867 public function recordOption( $option ) {
868 $this->mAccessedOptions
[$option] = true;
872 * Attaches arbitrary data to this ParserObject. This can be used to store some information in
873 * the ParserOutput object for later use during page output. The data will be cached along with
874 * the ParserOutput object, but unlike data set using setProperty(), it is not recorded in the
877 * This method is provided to overcome the unsafe practice of attaching extra information to a
878 * ParserObject by directly assigning member variables.
880 * To use setExtensionData() to pass extension information from a hook inside the parser to a
881 * hook in the page output, use this in the parser hook:
885 * $parser->getOutput()->setExtensionData( 'my_ext_foo', '...' );
888 * And then later, in OutputPageParserOutput or similar:
892 * $output->getExtensionData( 'my_ext_foo' );
895 * In MediaWiki 1.20 and older, you have to use a custom member variable
896 * within the ParserOutput object:
900 * $parser->getOutput()->my_ext_foo = '...';
905 * @param string $key The key for accessing the data. Extensions should take care to avoid
906 * conflicts in naming keys. It is suggested to use the extension's name as a prefix.
908 * @param mixed $value The value to set. Setting a value to null is equivalent to removing
911 public function setExtensionData( $key, $value ) {
912 if ( $value === null ) {
913 unset( $this->mExtensionData
[$key] );
915 $this->mExtensionData
[$key] = $value;
920 * Gets extensions data previously attached to this ParserOutput using setExtensionData().
921 * Typically, such data would be set while parsing the page, e.g. by a parser function.
925 * @param string $key The key to look up.
927 * @return mixed|null The value previously set for the given key using setExtensionData()
928 * or null if no value was set for this key.
930 public function getExtensionData( $key ) {
931 if ( isset( $this->mExtensionData
[$key] ) ) {
932 return $this->mExtensionData
[$key];
938 private static function getTimes( $clock = null ) {
940 if ( !$clock ||
$clock === 'wall' ) {
941 $ret['wall'] = microtime( true );
943 if ( !$clock ||
$clock === 'cpu' ) {
946 $ret['cpu'] = $ru['ru_utime.tv_sec'] +
$ru['ru_utime.tv_usec'] / 1e6
;
947 $ret['cpu'] +
= $ru['ru_stime.tv_sec'] +
$ru['ru_stime.tv_usec'] / 1e6
;
954 * Resets the parse start timestamps for future calls to getTimeSinceStart()
957 public function resetParseStartTime() {
958 $this->mParseStartTime
= self
::getTimes();
962 * Returns the time since resetParseStartTime() was last called
964 * Clocks available are:
965 * - wall: Wall clock time
966 * - cpu: CPU time (requires getrusage)
969 * @param string $clock
972 public function getTimeSinceStart( $clock ) {
973 if ( !isset( $this->mParseStartTime
[$clock] ) ) {
977 $end = self
::getTimes( $clock );
978 return $end[$clock] - $this->mParseStartTime
[$clock];
982 * Sets parser limit report data for a key
984 * The key is used as the prefix for various messages used for formatting:
985 * - $key: The label for the field in the limit report
986 * - $key-value-text: Message used to format the value in the "NewPP limit
987 * report" HTML comment. If missing, uses $key-format.
988 * - $key-value-html: Message used to format the value in the preview
989 * limit report table. If missing, uses $key-format.
990 * - $key-value: Message used to format the value. If missing, uses "$1".
992 * Note that all values are interpreted as wikitext, and so should be
993 * encoded with htmlspecialchars() as necessary, but should avoid complex
994 * HTML for sanity of display in the "NewPP limit report" comment.
997 * @param string $key Message key
998 * @param mixed $value Appropriate for Message::params()
1000 public function setLimitReportData( $key, $value ) {
1001 $this->mLimitReportData
[$key] = $value;
1005 * Check whether the cache TTL was lowered due to dynamic content
1007 * When content is determined by more than hard state (e.g. page edits),
1008 * such as template/file transclusions based on the current timestamp or
1009 * extension tags that generate lists based on queries, this return true.
1014 public function hasDynamicContent() {
1015 global $wgParserCacheExpireTime;
1017 return $this->getCacheExpiry() < $wgParserCacheExpireTime;
1021 * Get or set the prevent-clickjacking flag
1024 * @param bool|null $flag New flag value, or null to leave it unchanged
1025 * @return bool Old flag value
1027 public function preventClickjacking( $flag = null ) {
1028 return wfSetVar( $this->mPreventClickjacking
, $flag );
1032 * Save space for serialization by removing useless values
1035 public function __sleep() {
1037 array_keys( get_object_vars( $this ) ),
1038 [ 'mParseStartTime' ]