Array mapping interwiki prefix to (non DB key) Titles (e.g. 'fr' => 'Test page') */ private $mLanguageLinkMap = []; /** * @var array Map of category names to sort keys */ private $mCategories = []; /** * @var array Page status indicators, usually displayed in top-right corner. */ private array $mIndicators = []; /** * @var string Title text of the chosen language variant, as HTML. */ private $mTitleText; /** * @var array> 2-D map of NS/DBK to ID for the links in the document. * ID=zero for broken. */ private $mLinks = []; /** * @var array Keys are DBKs for the links to special pages in the document. * @since 1.35 */ private $mLinksSpecial = []; /** * @var array> 2-D map of NS/DBK to ID for the template references. * ID=zero for broken. */ private $mTemplates = []; /** * @var array> 2-D map of NS/DBK to rev ID for the template references. * ID=zero for broken. */ private $mTemplateIds = []; /** * @var array DB keys of the images used, in the array key only */ private $mImages = []; /** * @var array> DB keys of the images used mapped to sha1 and MW timestamp. */ private $mFileSearchOptions = []; /** * @var array External link URLs, in the key only. */ private array $mExternalLinks = []; /** * @var array> 2-D map of prefix/DBK (in keys only) * for the inline interwiki links in the document. */ private $mInterwikiLinks = []; /** * @var bool Show a new section link? */ private $mNewSection = false; /** * @var bool Hide the new section link? */ private $mHideNewSection = false; /** * @var bool No gallery on category page? (__NOGALLERY__). */ private $mNoGallery = false; /** * @var string[] Items to put in the section */ private $mHeadItems = []; /** * @var array Modules to be loaded by ResourceLoader */ private $mModuleSet = []; /** * @var array Modules of which only the CSS will be loaded by ResourceLoader. */ private $mModuleStyleSet = []; /** * @var array JavaScript config variable for mw.config combined with this page. */ private $mJsConfigVars = []; /** * @var array Warning text to be returned to the user. * Wikitext formatted, in the key only. */ private $mWarnings = []; /** * @var array *Unformatted* warning messages and * arguments to be returned to the user. This is for internal use * when merging ParserOutputs and are not serialized/deserialized. */ private $mWarningMsgs = []; /** * @var ?TOCData Table of contents data, or null if it hasn't been set. */ private $mTOCData; /** * @var array Name/value pairs to be cached in the DB. */ private $mProperties = []; /** * @var ?string Timestamp of the revision. */ private $mTimestamp; /** * @var bool Whether OOUI should be enabled. */ private $mEnableOOUI = false; /** * @var bool Whether the index policy has been set to 'index'. */ private $mIndexSet = false; /** * @var bool Whether the index policy has been set to 'noindex'. */ private $mNoIndexSet = false; /** * @var array extra data used by extensions. */ private $mExtensionData = []; /** * @var array Parser limit report data. */ private $mLimitReportData = []; /** @var array Parser limit report data for JSON */ private $mLimitReportJSData = []; /** @var string Debug message added by ParserCache */ private $mCacheMessage = ''; /** * @var array Timestamps for getTimeSinceStart(). */ private $mParseStartTime = []; /** * @var array Durations for getTimeProfile(). */ private $mTimeProfile = []; /** * @var bool Whether to emit X-Frame-Options: DENY. * This controls if anti-clickjacking / frame-breaking headers will * be sent. This should be done for pages where edit actions are possible. */ private $mPreventClickjacking = false; /** * @var string[] Extra script-src for CSP */ private $mExtraScriptSrcs = []; /** * @var string[] Extra default-src for CSP [Everything but script and style] */ private $mExtraDefaultSrcs = []; /** * @var string[] Extra style-src for CSP */ private $mExtraStyleSrcs = []; /** * @var array Generic flags. */ private $mFlags = []; private const SPECULATIVE_FIELDS = [ 'speculativePageIdUsed', 'mSpeculativeRevId', 'revisionTimestampUsed', ]; /** @var int|null Assumed rev ID for {{REVISIONID}} if no revision is set */ private $mSpeculativeRevId; /** @var int|null Assumed page ID for {{PAGEID}} if no revision is set */ private $speculativePageIdUsed; /** @var string|null Assumed rev timestamp for {{REVISIONTIMESTAMP}} if no revision is set */ private $revisionTimestampUsed; /** @var string|null SHA-1 base 36 hash of any self-transclusion */ private $revisionUsedSha1Base36; /** string CSS classes to use for the wrapping div, stored in the array keys. * If no class is given, no wrapper is added. * @var array */ private $mWrapperDivClasses = []; /** @var int Upper bound of expiry based on parse duration */ private $mMaxAdaptiveExpiry = INF; // finalizeAdaptiveCacheExpiry() uses TTL = MAX( m * PARSE_TIME + b, MIN_AR_TTL) // Current values imply that m=3933.333333 and b=-333.333333 // See https://www.nngroup.com/articles/website-response-times/ private const PARSE_FAST_SEC = 0.100; // perceived "fast" page parse private const PARSE_SLOW_SEC = 1.0; // perceived "slow" page parse private const FAST_AR_TTL = 60; // adaptive TTL for "fast" pages private const SLOW_AR_TTL = 3600; // adaptive TTL for "slow" pages private const MIN_AR_TTL = 15; // min adaptive TTL (for pool counter, and edit stashing) /** * @param string|null $text HTML. Use null to indicate that this ParserOutput contains only * meta-data, and the HTML output is undetermined, as opposed to empty. Passing null * here causes hasText() to return false. In 1.39 the default value changed from '' * to null. * @param array $languageLinks * @param array $categoryLinks * @param bool $unused * @param string $titletext */ public function __construct( $text = null, $languageLinks = [], $categoryLinks = [], $unused = false, $titletext = '' ) { $this->mRawText = $text; $this->mCategories = $categoryLinks; $this->mTitleText = $titletext; if ( $languageLinks === null ) { // T376323 wfDeprecated( __METHOD__ . ' with null $languageLinks', '1.43' ); } foreach ( ( $languageLinks ?? [] ) as $ll ) { $this->addLanguageLink( $ll ); } // If the content handler does not specify an alternative (by // calling ::resetParseStartTime() at a later point) then use // the creation of the ParserOutput as the "start of parse" time. $this->resetParseStartTime(); } /** * Returns true if text was passed to the constructor, or set using setText(). Returns false * if null was passed to the $text parameter of the constructor to indicate that this * ParserOutput only contains meta-data, and the HTML output is undetermined. * * @since 1.32 * * @return bool Whether this ParserOutput contains rendered text. If this returns false, the * ParserOutput contains meta-data only. */ public function hasText(): bool { return ( $this->mRawText !== null ); } /** * Get the cacheable text with markers still in it. The * return value is suitable for writing back via setText() but is not valid * for display to the user. * * @return string * @since 1.27 */ public function getRawText() { if ( $this->mRawText === null ) { throw new LogicException( 'This ParserOutput contains no text!' ); } return $this->mRawText; } /** * Get the output HTML * * T293512: in the future, ParserOutput::getText() will be deprecated in favor of invoking * the OutputTransformPipeline directly on a ParserOutput. * @param array $options (since 1.31) Transformations to apply to the HTML * - allowClone: (bool) Whether to clone the ParserOutput before * applying transformations. Default is false. * - allowTOC: (bool) Show the TOC, assuming there were enough headings * to generate one and `__NOTOC__` wasn't used. Default is true, * but might be statefully overridden. * - injectTOC: (bool) Replace the TOC_PLACEHOLDER with TOC contents; * otherwise the marker will be left in the article (and the skin * will be responsible for replacing or removing it). Default is * true. * - enableSectionEditLinks: (bool) Include section edit links, assuming * section edit link tokens are present in the HTML. Default is true, * but might be statefully overridden. * - userLang: (Language) Language object used for localizing UX messages, * for example the heading of the table of contents. If omitted, will * use the language of the main request context. * - skin: (Skin) Skin object used for transforming section edit links. * - unwrap: (bool) Return text without a wrapper div. Default is false, * meaning a wrapper div will be added if getWrapperDivClass() returns * a non-empty string. * - wrapperDivClass: (string) Wrap the output in a div and apply the given * CSS class to that div. This overrides the output of getWrapperDivClass(). * Setting this to an empty string has the same effect as 'unwrap' => true. * - deduplicateStyles: (bool) When true, which is the default, `