MediaWiki  master
ParserOutput.php
Go to the documentation of this file.
1 <?php
2 
25 class ParserOutput extends CacheTime {
33 
37  public const SUPPORTS_UNWRAP_TRANSFORM = 1;
38 
42  public $mText = null;
43 
49 
53  public $mCategories;
54 
58  public $mIndicators = [];
59 
63  public $mTitleText;
64 
70  public $mLinks = [];
71 
76  public $mLinksSpecial = [];
77 
82  public $mTemplates = [];
83 
88  public $mTemplateIds = [];
89 
93  public $mImages = [];
94 
98  public $mFileSearchOptions = [];
99 
103  public $mExternalLinks = [];
104 
109  public $mInterwikiLinks = [];
110 
114  public $mNewSection = false;
115 
119  public $mHideNewSection = false;
120 
124  public $mNoGallery = false;
125 
129  public $mHeadItems = [];
130 
134  public $mModules = [];
135 
139  public $mModuleStyles = [];
140 
144  public $mJsConfigVars = [];
145 
149  public $mOutputHooks = [];
150 
155  public $mWarnings = [];
156 
160  public $mSections = [];
161 
165  public $mProperties = [];
166 
170  public $mTOCHTML = '';
171 
175  public $mTimestamp;
176 
180  public $mEnableOOUI = false;
181 
185  private $mIndexPolicy = '';
186 
190  private $mAccessedOptions = [];
191 
195  private $mExtensionData = [];
196 
200  private $mLimitReportData = [];
201 
203  private $mLimitReportJSData = [];
204 
208  private $mParseStartTime = [];
209 
213  private $mPreventClickjacking = false;
214 
218  private $mExtraScriptSrcs = [];
219 
223  private $mExtraDefaultSrcs = [];
224 
228  private $mExtraStyleSrcs = [];
229 
233  private $mFlags = [];
234 
236  private const SPECULATIVE_FIELDS = [
237  'speculativePageIdUsed',
238  'mSpeculativeRevId',
239  'revisionTimestampUsed'
240  ];
241 
248 
251 
255  private $mWrapperDivClasses = [];
256 
258  private $mMaxAdaptiveExpiry = INF;
259 
260  private const EDITSECTION_REGEX =
261  '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#s';
262 
263  // finalizeAdaptiveCacheExpiry() uses TTL = MAX( m * PARSE_TIME + b, MIN_AR_TTL)
264  // Current values imply that m=3933.333333 and b=-333.333333
265  // See https://www.nngroup.com/articles/website-response-times/
266  private const PARSE_FAST_SEC = 0.100; // perceived "fast" page parse
267  private const PARSE_SLOW_SEC = 1.0; // perceived "slow" page parse
268  private const FAST_AR_TTL = 60; // adaptive TTL for "fast" pages
269  private const SLOW_AR_TTL = 3600; // adaptive TTL for "slow" pages
270  private const MIN_AR_TTL = 15; // min adaptive TTL (for sanity, pool counter, and edit stashing)
271 
281  public function __construct( $text = '', $languageLinks = [], $categoryLinks = [],
282  $unused = false, $titletext = ''
283  ) {
284  $this->mText = $text;
285  $this->mLanguageLinks = $languageLinks;
286  $this->mCategories = $categoryLinks;
287  $this->mTitleText = $titletext;
288  }
289 
300  public function hasText() {
301  return ( $this->mText !== null );
302  }
303 
312  public function getRawText() {
313  if ( $this->mText === null ) {
314  throw new LogicException( 'This ParserOutput contains no text!' );
315  }
316 
317  return $this->mText;
318  }
319 
346  public function getText( $options = [] ) {
347  $options += [
348  'allowTOC' => true,
349  'enableSectionEditLinks' => true,
350  'skin' => null,
351  'unwrap' => false,
352  'deduplicateStyles' => true,
353  'wrapperDivClass' => $this->getWrapperDivClass(),
354  ];
355  $text = $this->getRawText();
356 
357  Hooks::runner()->onParserOutputPostCacheTransform( $this, $text, $options );
358 
359  if ( $options['wrapperDivClass'] !== '' && !$options['unwrap'] ) {
360  $text = Html::rawElement( 'div', [ 'class' => $options['wrapperDivClass'] ], $text );
361  }
362 
363  if ( $options['enableSectionEditLinks'] ) {
364  // TODO: Passing the skin should be required
365  $skin = $options['skin'] ?: RequestContext::getMain()->getSkin();
366 
367  $text = preg_replace_callback(
368  self::EDITSECTION_REGEX,
369  function ( $m ) use ( $skin ) {
370  $editsectionPage = Title::newFromText( htmlspecialchars_decode( $m[1] ) );
371  $editsectionSection = htmlspecialchars_decode( $m[2] );
372  $editsectionContent = isset( $m[4] ) ? Sanitizer::decodeCharReferences( $m[3] ) : null;
373 
374  if ( !is_object( $editsectionPage ) ) {
375  throw new MWException( "Bad parser output text." );
376  }
377 
378  return $skin->doEditSectionLink(
379  $editsectionPage,
380  $editsectionSection,
381  $editsectionContent,
382  $skin->getLanguage()
383  );
384  },
385  $text
386  );
387  } else {
388  $text = preg_replace( self::EDITSECTION_REGEX, '', $text );
389  }
390 
391  if ( $options['allowTOC'] ) {
392  $text = str_replace( [ Parser::TOC_START, Parser::TOC_END ], '', $text );
393  } else {
394  $text = preg_replace(
395  '#' . preg_quote( Parser::TOC_START, '#' ) . '.*?' . preg_quote( Parser::TOC_END, '#' ) . '#s',
396  '',
397  $text
398  );
399  }
400 
401  if ( $options['deduplicateStyles'] ) {
402  $seen = [];
403  $text = preg_replace_callback(
404  '#<style\s+([^>]*data-mw-deduplicate\s*=[^>]*)>.*?</style>#s',
405  function ( $m ) use ( &$seen ) {
406  $attr = Sanitizer::decodeTagAttributes( $m[1] );
407  if ( !isset( $attr['data-mw-deduplicate'] ) ) {
408  return $m[0];
409  }
410 
411  $key = $attr['data-mw-deduplicate'];
412  if ( !isset( $seen[$key] ) ) {
413  $seen[$key] = true;
414  return $m[0];
415  }
416 
417  // We were going to use an empty <style> here, but there
418  // was concern that would be too much overhead for browsers.
419  // So let's hope a <link> with a non-standard rel and href isn't
420  // going to be misinterpreted or mangled by any subsequent processing.
421  return Html::element( 'link', [
422  'rel' => 'mw-deduplicated-inline-style',
423  'href' => "mw-data:" . wfUrlencode( $key ),
424  ] );
425  },
426  $text
427  );
428  }
429 
430  // Hydrate slot section header placeholders generated by RevisionRenderer.
431  $text = preg_replace_callback(
432  '#<mw:slotheader>(.*?)</mw:slotheader>#',
433  function ( $m ) {
434  $role = htmlspecialchars_decode( $m[1] );
435  // TODO: map to message, using the interface language. Set lang="xyz" accordingly.
436  $headerText = $role;
437  return $headerText;
438  },
439  $text
440  );
441  return $text;
442  }
443 
449  public function addWrapperDivClass( $class ) {
450  $this->mWrapperDivClasses[$class] = true;
451  }
452 
457  public function clearWrapperDivClass() {
458  $this->mWrapperDivClasses = [];
459  }
460 
468  public function getWrapperDivClass() {
469  return implode( ' ', array_keys( $this->mWrapperDivClasses ) );
470  }
471 
476  public function setSpeculativeRevIdUsed( $id ) {
477  $this->mSpeculativeRevId = $id;
478  }
479 
484  public function getSpeculativeRevIdUsed() {
486  }
487 
492  public function setSpeculativePageIdUsed( $id ) {
493  $this->speculativePageIdUsed = $id;
494  }
495 
500  public function getSpeculativePageIdUsed() {
502  }
503 
508  public function setRevisionTimestampUsed( $timestamp ) {
509  $this->revisionTimestampUsed = $timestamp;
510  }
511 
516  public function getRevisionTimestampUsed() {
518  }
519 
524  public function setRevisionUsedSha1Base36( $hash ) {
525  if ( $hash === null ) {
526  return; // e.g. RevisionRecord::getSha1() returned null
527  }
528 
529  if (
530  $this->revisionUsedSha1Base36 !== null &&
531  $this->revisionUsedSha1Base36 !== $hash
532  ) {
533  $this->revisionUsedSha1Base36 = ''; // mismatched
534  } else {
535  $this->revisionUsedSha1Base36 = $hash;
536  }
537  }
538 
543  public function getRevisionUsedSha1Base36() {
545  }
546 
547  public function &getLanguageLinks() {
548  return $this->mLanguageLinks;
549  }
550 
551  public function getInterwikiLinks() {
552  return $this->mInterwikiLinks;
553  }
554 
555  public function getCategoryLinks() {
556  return array_keys( $this->mCategories );
557  }
558 
559  public function &getCategories() {
560  return $this->mCategories;
561  }
562 
567  public function getIndicators() {
568  return $this->mIndicators;
569  }
570 
571  public function getTitleText() {
572  return $this->mTitleText;
573  }
574 
575  public function getSections() {
576  return $this->mSections;
577  }
578 
579  public function &getLinks() {
580  return $this->mLinks;
581  }
582 
587  public function &getLinksSpecial() {
588  return $this->mLinksSpecial;
589  }
590 
591  public function &getTemplates() {
592  return $this->mTemplates;
593  }
594 
595  public function &getTemplateIds() {
596  return $this->mTemplateIds;
597  }
598 
599  public function &getImages() {
600  return $this->mImages;
601  }
602 
603  public function &getFileSearchOptions() {
605  }
606 
607  public function &getExternalLinks() {
608  return $this->mExternalLinks;
609  }
610 
611  public function setNoGallery( $value ) {
612  $this->mNoGallery = (bool)$value;
613  }
614 
615  public function getNoGallery() {
616  return $this->mNoGallery;
617  }
618 
619  public function getHeadItems() {
620  return $this->mHeadItems;
621  }
622 
623  public function getModules() {
624  return $this->mModules;
625  }
626 
627  public function getModuleStyles() {
628  return $this->mModuleStyles;
629  }
630 
635  public function getJsConfigVars() {
636  return $this->mJsConfigVars;
637  }
638 
639  public function getOutputHooks() {
640  return (array)$this->mOutputHooks;
641  }
642 
643  public function getWarnings() {
644  return array_keys( $this->mWarnings );
645  }
646 
647  public function getIndexPolicy() {
648  return $this->mIndexPolicy;
649  }
650 
651  public function getTOCHTML() {
652  return $this->mTOCHTML;
653  }
654 
658  public function getTimestamp() {
659  return $this->mTimestamp;
660  }
661 
662  public function getLimitReportData() {
664  }
665 
666  public function getLimitReportJSData() {
668  }
669 
670  public function getEnableOOUI() {
671  return $this->mEnableOOUI;
672  }
673 
679  public function getExtraCSPDefaultSrcs() {
681  }
682 
688  public function getExtraCSPScriptSrcs() {
690  }
691 
697  public function getExtraCSPStyleSrcs() {
698  return $this->mExtraStyleSrcs;
699  }
700 
701  public function setText( $text ) {
702  return wfSetVar( $this->mText, $text );
703  }
704 
705  public function setLanguageLinks( $ll ) {
706  return wfSetVar( $this->mLanguageLinks, $ll );
707  }
708 
709  public function setCategoryLinks( $cl ) {
710  return wfSetVar( $this->mCategories, $cl );
711  }
712 
713  public function setTitleText( $t ) {
714  return wfSetVar( $this->mTitleText, $t );
715  }
716 
717  public function setSections( $toc ) {
718  return wfSetVar( $this->mSections, $toc );
719  }
720 
721  public function setIndexPolicy( $policy ) {
722  return wfSetVar( $this->mIndexPolicy, $policy );
723  }
724 
725  public function setTOCHTML( $tochtml ) {
726  return wfSetVar( $this->mTOCHTML, $tochtml );
727  }
728 
729  public function setTimestamp( $timestamp ) {
730  return wfSetVar( $this->mTimestamp, $timestamp );
731  }
732 
733  public function addCategory( $c, $sort ) {
734  $this->mCategories[$c] = $sort;
735  }
736 
742  public function setIndicator( $id, $content ) {
743  $this->mIndicators[$id] = $content;
744  }
745 
753  public function setEnableOOUI( $enable = false ) {
754  $this->mEnableOOUI = $enable;
755  }
756 
757  public function addLanguageLink( $t ) {
758  $this->mLanguageLinks[] = $t;
759  }
760 
761  public function addWarning( $s ) {
762  $this->mWarnings[$s] = 1;
763  }
764 
765  public function addOutputHook( $hook, $data = false ) {
766  $this->mOutputHooks[] = [ $hook, $data ];
767  }
768 
769  public function setNewSection( $value ) {
770  $this->mNewSection = (bool)$value;
771  }
772 
773  public function hideNewSection( $value ) {
774  $this->mHideNewSection = (bool)$value;
775  }
776 
777  public function getHideNewSection() {
778  return (bool)$this->mHideNewSection;
779  }
780 
781  public function getNewSection() {
782  return (bool)$this->mNewSection;
783  }
784 
792  public static function isLinkInternal( $internal, $url ) {
793  return (bool)preg_match( '/^' .
794  # If server is proto relative, check also for http/https links
795  ( substr( $internal, 0, 2 ) === '//' ? '(?:https?:)?' : '' ) .
796  preg_quote( $internal, '/' ) .
797  # check for query/path/anchor or end of link in each case
798  '(?:[\?\/\#]|$)/i',
799  $url
800  );
801  }
802 
803  public function addExternalLink( $url ) {
804  # We don't register links pointing to our own server, unless... :-)
806 
807  # Replace unnecessary URL escape codes with the referenced character
808  # This prevents spammers from hiding links from the filters
809  $url = Parser::normalizeLinkUrl( $url );
810 
811  $registerExternalLink = true;
813  $registerExternalLink = !self::isLinkInternal( $wgServer, $url );
814  }
815  if ( $registerExternalLink ) {
816  $this->mExternalLinks[$url] = 1;
817  }
818  }
819 
826  public function addLink( Title $title, $id = null ) {
827  if ( $title->isExternal() ) {
828  // Don't record interwikis in pagelinks
829  $this->addInterwikiLink( $title );
830  return;
831  }
832  $ns = $title->getNamespace();
833  $dbk = $title->getDBkey();
834  if ( $ns === NS_MEDIA ) {
835  // Normalize this pseudo-alias if it makes it down here...
836  $ns = NS_FILE;
837  } elseif ( $ns === NS_SPECIAL ) {
838  // We don't want to record Special: links in the database, so put them in a separate place.
839  // It might actually be wise to, but we'd need to do some normalization.
840  $this->mLinksSpecial[$dbk] = 1;
841  return;
842  } elseif ( $dbk === '' ) {
843  // Don't record self links - [[#Foo]]
844  return;
845  }
846  if ( !isset( $this->mLinks[$ns] ) ) {
847  $this->mLinks[$ns] = [];
848  }
849  if ( $id === null ) {
850  $id = $title->getArticleID();
851  }
852  $this->mLinks[$ns][$dbk] = $id;
853  }
854 
861  public function addImage( $name, $timestamp = null, $sha1 = null ) {
862  $this->mImages[$name] = 1;
863  if ( $timestamp !== null && $sha1 !== null ) {
864  $this->mFileSearchOptions[$name] = [ 'time' => $timestamp, 'sha1' => $sha1 ];
865  }
866  }
867 
874  public function addTemplate( $title, $page_id, $rev_id ) {
875  $ns = $title->getNamespace();
876  $dbk = $title->getDBkey();
877  if ( !isset( $this->mTemplates[$ns] ) ) {
878  $this->mTemplates[$ns] = [];
879  }
880  $this->mTemplates[$ns][$dbk] = $page_id;
881  if ( !isset( $this->mTemplateIds[$ns] ) ) {
882  $this->mTemplateIds[$ns] = [];
883  }
884  $this->mTemplateIds[$ns][$dbk] = $rev_id; // For versioning
885  }
886 
891  public function addInterwikiLink( $title ) {
892  if ( !$title->isExternal() ) {
893  throw new MWException( 'Non-interwiki link passed, internal parser error.' );
894  }
895  $prefix = $title->getInterwiki();
896  if ( !isset( $this->mInterwikiLinks[$prefix] ) ) {
897  $this->mInterwikiLinks[$prefix] = [];
898  }
899  $this->mInterwikiLinks[$prefix][$title->getDBkey()] = 1;
900  }
901 
909  public function addHeadItem( $section, $tag = false ) {
910  if ( $tag !== false ) {
911  $this->mHeadItems[$tag] = $section;
912  } else {
913  $this->mHeadItems[] = $section;
914  }
915  }
916 
921  public function addModules( $modules ) {
922  $this->mModules = array_merge( $this->mModules, (array)$modules );
923  }
924 
929  public function addModuleStyles( $modules ) {
930  $this->mModuleStyles = array_merge( $this->mModuleStyles, (array)$modules );
931  }
932 
940  public function addJsConfigVars( $keys, $value = null ) {
941  if ( is_array( $keys ) ) {
942  foreach ( $keys as $key => $value ) {
943  $this->mJsConfigVars[$key] = $value;
944  }
945  return;
946  }
947 
948  $this->mJsConfigVars[$keys] = $value;
949  }
950 
956  public function addOutputPageMetadata( OutputPage $out ) {
957  $this->addModules( $out->getModules() );
958  $this->addModuleStyles( $out->getModuleStyles() );
959  $this->addJsConfigVars( $out->getJsConfigVars() );
960 
961  $this->mHeadItems = array_merge( $this->mHeadItems, $out->getHeadItemsArray() );
962  $this->mPreventClickjacking = $this->mPreventClickjacking || $out->getPreventClickjacking();
963  }
964 
981  public function addTrackingCategory( $msg, $title ) {
982  if ( $title->isSpecialPage() ) {
983  wfDebug( __METHOD__ . ": Not adding tracking category $msg to special page!" );
984  return false;
985  }
986 
987  // Important to parse with correct title (T33469)
988  $cat = wfMessage( $msg )
989  ->title( $title )
990  ->inContentLanguage()
991  ->text();
992 
993  # Allow tracking categories to be disabled by setting them to "-"
994  if ( $cat === '-' ) {
995  return false;
996  }
997 
998  $containerCategory = Title::makeTitleSafe( NS_CATEGORY, $cat );
999  if ( $containerCategory ) {
1000  $this->addCategory( $containerCategory->getDBkey(), $this->getProperty( 'defaultsort' ) ?: '' );
1001  return true;
1002  } else {
1003  wfDebug( __METHOD__ . ": [[MediaWiki:$msg]] is not a valid title!" );
1004  return false;
1005  }
1006  }
1007 
1019  public function setDisplayTitle( $text ) {
1020  $this->setTitleText( $text );
1021  $this->setProperty( 'displaytitle', $text );
1022  }
1023 
1032  public function getDisplayTitle() {
1033  $t = $this->getTitleText();
1034  if ( $t === '' ) {
1035  return false;
1036  }
1037  return $t;
1038  }
1039 
1045  public function setFlag( $flag ) {
1046  $this->mFlags[$flag] = true;
1047  }
1048 
1053  public function getFlag( $flag ) {
1054  return isset( $this->mFlags[$flag] );
1055  }
1056 
1061  public function getAllFlags() {
1062  return array_keys( $this->mFlags );
1063  }
1064 
1125  public function setProperty( $name, $value ) {
1126  $this->mProperties[$name] = $value;
1127  }
1128 
1137  public function getProperty( $name ) {
1138  return $this->mProperties[$name] ?? false;
1139  }
1140 
1141  public function unsetProperty( $name ) {
1142  unset( $this->mProperties[$name] );
1143  }
1144 
1145  public function getProperties() {
1146  if ( !isset( $this->mProperties ) ) {
1147  $this->mProperties = [];
1148  }
1149  return $this->mProperties;
1150  }
1151 
1157  public function getUsedOptions() {
1158  if ( !isset( $this->mAccessedOptions ) ) {
1159  return [];
1160  }
1161  return array_keys( $this->mAccessedOptions );
1162  }
1163 
1176  public function recordOption( $option ) {
1177  $this->mAccessedOptions[$option] = true;
1178  }
1179 
1220  public function setExtensionData( $key, $value ) {
1221  if ( $value === null ) {
1222  unset( $this->mExtensionData[$key] );
1223  } else {
1224  $this->mExtensionData[$key] = $value;
1225  }
1226  }
1227 
1239  public function getExtensionData( $key ) {
1240  return $this->mExtensionData[$key] ?? null;
1241  }
1242 
1243  private static function getTimes( $clock = null ) {
1244  $ret = [];
1245  if ( !$clock || $clock === 'wall' ) {
1246  $ret['wall'] = microtime( true );
1247  }
1248  if ( !$clock || $clock === 'cpu' ) {
1249  $ru = getrusage( 0 /* RUSAGE_SELF */ );
1250  $ret['cpu'] = $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1e6;
1251  $ret['cpu'] += $ru['ru_stime.tv_sec'] + $ru['ru_stime.tv_usec'] / 1e6;
1252  }
1253  return $ret;
1254  }
1255 
1260  public function resetParseStartTime() {
1261  $this->mParseStartTime = self::getTimes();
1262  }
1263 
1275  public function getTimeSinceStart( $clock ) {
1276  if ( !isset( $this->mParseStartTime[$clock] ) ) {
1277  return null;
1278  }
1279 
1280  $end = self::getTimes( $clock );
1281  return $end[$clock] - $this->mParseStartTime[$clock];
1282  }
1283 
1303  public function setLimitReportData( $key, $value ) {
1304  $this->mLimitReportData[$key] = $value;
1305 
1306  if ( is_array( $value ) ) {
1307  if ( array_keys( $value ) === [ 0, 1 ]
1308  && is_numeric( $value[0] )
1309  && is_numeric( $value[1] )
1310  ) {
1311  $data = [ 'value' => $value[0], 'limit' => $value[1] ];
1312  } else {
1313  $data = $value;
1314  }
1315  } else {
1316  $data = $value;
1317  }
1318 
1319  if ( strpos( $key, '-' ) ) {
1320  list( $ns, $name ) = explode( '-', $key, 2 );
1321  $this->mLimitReportJSData[$ns][$name] = $data;
1322  } else {
1323  $this->mLimitReportJSData[$key] = $data;
1324  }
1325  }
1326 
1337  public function hasDynamicContent() {
1338  global $wgParserCacheExpireTime;
1339 
1340  return $this->getCacheExpiry() < $wgParserCacheExpireTime;
1341  }
1342 
1350  public function preventClickjacking( $flag = null ) {
1351  return wfSetVar( $this->mPreventClickjacking, $flag );
1352  }
1353 
1360  public function updateRuntimeAdaptiveExpiry( $ttl ) {
1361  $this->mMaxAdaptiveExpiry = min( $ttl, $this->mMaxAdaptiveExpiry );
1362  $this->updateCacheExpiry( $ttl );
1363  }
1364 
1374  public function addExtraCSPDefaultSrc( $src ) {
1375  $this->mExtraDefaultSrcs[] = $src;
1376  }
1377 
1384  public function addExtraCSPStyleSrc( $src ) {
1385  $this->mExtraStyleSrcs[] = $src;
1386  }
1387 
1396  public function addExtraCSPScriptSrc( $src ) {
1397  $this->mExtraScriptSrcs[] = $src;
1398  }
1399 
1405  public function finalizeAdaptiveCacheExpiry() {
1406  if ( is_infinite( $this->mMaxAdaptiveExpiry ) ) {
1407  return; // not set
1408  }
1409 
1410  $runtime = $this->getTimeSinceStart( 'wall' );
1411  if ( is_float( $runtime ) ) {
1412  $slope = ( self::SLOW_AR_TTL - self::FAST_AR_TTL )
1413  / ( self::PARSE_SLOW_SEC - self::PARSE_FAST_SEC );
1414  // SLOW_AR_TTL = PARSE_SLOW_SEC * $slope + $point
1415  $point = self::SLOW_AR_TTL - self::PARSE_SLOW_SEC * $slope;
1416 
1417  $adaptiveTTL = min(
1418  max( $slope * $runtime + $point, self::MIN_AR_TTL ),
1419  $this->mMaxAdaptiveExpiry
1420  );
1421  $this->updateCacheExpiry( $adaptiveTTL );
1422  }
1423  }
1424 
1425  public function __sleep() {
1426  return array_filter( array_keys( get_object_vars( $this ) ),
1427  function ( $field ) {
1428  if ( $field === 'mParseStartTime' ) {
1429  return false;
1430  } elseif ( strpos( $field, "\0" ) !== false ) {
1431  // Unserializing unknown private fields in HHVM causes
1432  // member variables with nulls in their names (T229366)
1433  return false;
1434  } else {
1435  return true;
1436  }
1437  }
1438  );
1439  }
1440 
1449  $this->mOutputHooks = self::mergeList( $this->mOutputHooks, $source->getOutputHooks() );
1450  $this->mWarnings = self::mergeMap( $this->mWarnings, $source->mWarnings ); // don't use getter
1451  $this->mTimestamp = $this->useMaxValue( $this->mTimestamp, $source->getTimestamp() );
1452 
1453  foreach ( self::SPECULATIVE_FIELDS as $field ) {
1454  if ( $this->$field && $source->$field && $this->$field !== $source->$field ) {
1455  wfLogWarning( __METHOD__ . ": inconsistent '$field' properties!" );
1456  }
1457  $this->$field = $this->useMaxValue( $this->$field, $source->$field );
1458  }
1459 
1460  $this->mParseStartTime = $this->useEachMinValue(
1461  $this->mParseStartTime,
1462  $source->mParseStartTime
1463  );
1464 
1465  $this->mFlags = self::mergeMap( $this->mFlags, $source->mFlags );
1466  $this->mAccessedOptions = self::mergeMap( $this->mAccessedOptions, $source->mAccessedOptions );
1467 
1468  // TODO: maintain per-slot limit reports!
1469  if ( empty( $this->mLimitReportData ) ) {
1470  $this->mLimitReportData = $source->mLimitReportData;
1471  }
1472  if ( empty( $this->mLimitReportJSData ) ) {
1473  $this->mLimitReportJSData = $source->mLimitReportJSData;
1474  }
1475  }
1476 
1485  // HTML and HTTP
1486  $this->mHeadItems = self::mergeMixedList( $this->mHeadItems, $source->getHeadItems() );
1487  $this->mModules = self::mergeList( $this->mModules, $source->getModules() );
1488  $this->mModuleStyles = self::mergeList( $this->mModuleStyles, $source->getModuleStyles() );
1489  $this->mJsConfigVars = self::mergeMap( $this->mJsConfigVars, $source->getJsConfigVars() );
1490  $this->mMaxAdaptiveExpiry = min( $this->mMaxAdaptiveExpiry, $source->mMaxAdaptiveExpiry );
1491  $this->mExtraStyleSrcs = self::mergeList(
1492  $this->mExtraStyleSrcs,
1493  $source->getExtraCSPStyleSrcs()
1494  );
1495  $this->mExtraScriptSrcs = self::mergeList(
1496  $this->mExtraScriptSrcs,
1497  $source->getExtraCSPScriptSrcs()
1498  );
1499  $this->mExtraDefaultSrcs = self::mergeList(
1500  $this->mExtraDefaultSrcs,
1501  $source->getExtraCSPDefaultSrcs()
1502  );
1503 
1504  // "noindex" always wins!
1505  if ( $this->mIndexPolicy === 'noindex' || $source->mIndexPolicy === 'noindex' ) {
1506  $this->mIndexPolicy = 'noindex';
1507  } elseif ( $this->mIndexPolicy !== 'index' ) {
1508  $this->mIndexPolicy = $source->mIndexPolicy;
1509  }
1510 
1511  // Skin control
1512  $this->mNewSection = $this->mNewSection || $source->getNewSection();
1513  $this->mHideNewSection = $this->mHideNewSection || $source->getHideNewSection();
1514  $this->mNoGallery = $this->mNoGallery || $source->getNoGallery();
1515  $this->mEnableOOUI = $this->mEnableOOUI || $source->getEnableOOUI();
1516  $this->mPreventClickjacking = $this->mPreventClickjacking || $source->preventClickjacking();
1517 
1518  // TODO: we'll have to be smarter about this!
1519  $this->mSections = array_merge( $this->mSections, $source->getSections() );
1520  $this->mTOCHTML .= $source->mTOCHTML;
1521 
1522  // XXX: we don't want to concatenate title text, so first write wins.
1523  // We should use the first *modified* title text, but we don't have the original to check.
1524  if ( $this->mTitleText === null || $this->mTitleText === '' ) {
1525  $this->mTitleText = $source->mTitleText;
1526  }
1527 
1528  // class names are stored in array keys
1529  $this->mWrapperDivClasses = self::mergeMap(
1530  $this->mWrapperDivClasses,
1531  $source->mWrapperDivClasses
1532  );
1533 
1534  // NOTE: last write wins, same as within one ParserOutput
1535  $this->mIndicators = self::mergeMap( $this->mIndicators, $source->getIndicators() );
1536 
1537  // NOTE: include extension data in "tracking meta data" as well as "html meta data"!
1538  // TODO: add a $mergeStrategy parameter to setExtensionData to allow different
1539  // kinds of extension data to be merged in different ways.
1540  $this->mExtensionData = self::mergeMap(
1541  $this->mExtensionData,
1542  $source->mExtensionData
1543  );
1544  }
1545 
1554  $this->mLanguageLinks = self::mergeList( $this->mLanguageLinks, $source->getLanguageLinks() );
1555  $this->mCategories = self::mergeMap( $this->mCategories, $source->getCategories() );
1556  $this->mLinks = self::merge2D( $this->mLinks, $source->getLinks() );
1557  $this->mTemplates = self::merge2D( $this->mTemplates, $source->getTemplates() );
1558  $this->mTemplateIds = self::merge2D( $this->mTemplateIds, $source->getTemplateIds() );
1559  $this->mImages = self::mergeMap( $this->mImages, $source->getImages() );
1560  $this->mFileSearchOptions = self::mergeMap(
1561  $this->mFileSearchOptions,
1562  $source->getFileSearchOptions()
1563  );
1564  $this->mExternalLinks = self::mergeMap( $this->mExternalLinks, $source->getExternalLinks() );
1565  $this->mInterwikiLinks = self::merge2D(
1566  $this->mInterwikiLinks,
1567  $source->getInterwikiLinks()
1568  );
1569 
1570  // TODO: add a $mergeStrategy parameter to setProperty to allow different
1571  // kinds of properties to be merged in different ways.
1572  $this->mProperties = self::mergeMap( $this->mProperties, $source->getProperties() );
1573 
1574  // NOTE: include extension data in "tracking meta data" as well as "html meta data"!
1575  // TODO: add a $mergeStrategy parameter to setExtensionData to allow different
1576  // kinds of extension data to be merged in different ways.
1577  $this->mExtensionData = self::mergeMap(
1578  $this->mExtensionData,
1579  $source->mExtensionData
1580  );
1581  }
1582 
1583  private static function mergeMixedList( array $a, array $b ) {
1584  return array_unique( array_merge( $a, $b ), SORT_REGULAR );
1585  }
1586 
1587  private static function mergeList( array $a, array $b ) {
1588  return array_values( array_unique( array_merge( $a, $b ), SORT_REGULAR ) );
1589  }
1590 
1591  private static function mergeMap( array $a, array $b ) {
1592  return array_replace( $a, $b );
1593  }
1594 
1595  private static function merge2D( array $a, array $b ) {
1596  $values = [];
1597  $keys = array_merge( array_keys( $a ), array_keys( $b ) );
1598 
1599  foreach ( $keys as $k ) {
1600  if ( empty( $a[$k] ) ) {
1601  $values[$k] = $b[$k];
1602  } elseif ( empty( $b[$k] ) ) {
1603  $values[$k] = $a[$k];
1604  } elseif ( is_array( $a[$k] ) && is_array( $b[$k] ) ) {
1605  $values[$k] = array_replace( $a[$k], $b[$k] );
1606  } else {
1607  $values[$k] = $b[$k];
1608  }
1609  }
1610 
1611  return $values;
1612  }
1613 
1614  private static function useEachMinValue( array $a, array $b ) {
1615  $values = [];
1616  $keys = array_merge( array_keys( $a ), array_keys( $b ) );
1617 
1618  foreach ( $keys as $k ) {
1619  if ( is_array( $a[$k] ?? null ) && is_array( $b[$k] ?? null ) ) {
1620  $values[$k] = self::useEachMinValue( $a[$k], $b[$k] );
1621  } else {
1622  $values[$k] = self::useMinValue( $a[$k] ?? null, $b[$k] ?? null );
1623  }
1624  }
1625 
1626  return $values;
1627  }
1628 
1629  private static function useMinValue( $a, $b ) {
1630  if ( $a === null ) {
1631  return $b;
1632  }
1633 
1634  if ( $b === null ) {
1635  return $a;
1636  }
1637 
1638  return min( $a, $b );
1639  }
1640 
1641  private static function useMaxValue( $a, $b ) {
1642  if ( $a === null ) {
1643  return $b;
1644  }
1645 
1646  if ( $b === null ) {
1647  return $a;
1648  }
1649 
1650  return max( $a, $b );
1651  }
1652 
1653 }
ParserOutput\$mImages
array $mImages
DB keys of the images used, in the array key only.
Definition: ParserOutput.php:93
ParserOutput\$mWrapperDivClasses
$mWrapperDivClasses
string CSS classes to use for the wrapping div, stored in the array keys.
Definition: ParserOutput.php:255
ParserOutput\addOutputPageMetadata
addOutputPageMetadata(OutputPage $out)
Copy items from the OutputPage object into this one.
Definition: ParserOutput.php:956
ParserOutput\getEnableOOUI
getEnableOOUI()
Definition: ParserOutput.php:670
ParserOutput\mergeMap
static mergeMap(array $a, array $b)
Definition: ParserOutput.php:1591
ParserOutput\$mEnableOOUI
bool $mEnableOOUI
Whether OOUI should be enabled.
Definition: ParserOutput.php:180
ParserOutput\$mWarnings
array $mWarnings
Warning text to be returned to the user.
Definition: ParserOutput.php:155
ParserOutput\$mJsConfigVars
array $mJsConfigVars
JavaScript config variable for mw.config combined with this page.
Definition: ParserOutput.php:144
CacheTime\getCacheExpiry
getCacheExpiry()
Returns the number of seconds after which this object should expire.
Definition: CacheTime.php:129
ParserOutput\$mFileSearchOptions
array $mFileSearchOptions
DB keys of the images used mapped to sha1 and MW timestamp.
Definition: ParserOutput.php:98
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:329
ParserOutput\setTitleText
setTitleText( $t)
Definition: ParserOutput.php:713
ParserOutput
Definition: ParserOutput.php:25
ParserOutput\setSpeculativeRevIdUsed
setSpeculativeRevIdUsed( $id)
Definition: ParserOutput.php:476
ParserOutput\SUPPORTS_UNWRAP_TRANSFORM
const SUPPORTS_UNWRAP_TRANSFORM
Definition: ParserOutput.php:37
CacheTime
Parser cache specific expiry check.
Definition: CacheTime.php:29
ParserOutput\resetParseStartTime
resetParseStartTime()
Resets the parse start timestamps for future calls to getTimeSinceStart()
Definition: ParserOutput.php:1260
ParserOutput\setDisplayTitle
setDisplayTitle( $text)
Override the title to be used for display.
Definition: ParserOutput.php:1019
ParserOutput\$mLanguageLinks
array $mLanguageLinks
List of the full text of language links, in the order they appear.
Definition: ParserOutput.php:48
ParserOutput\setTimestamp
setTimestamp( $timestamp)
Definition: ParserOutput.php:729
ParserOutput\getUsedOptions
getUsedOptions()
Returns the options from its ParserOptions which have been taken into account to produce this output.
Definition: ParserOutput.php:1157
ParserOutput\mergeMixedList
static mergeMixedList(array $a, array $b)
Definition: ParserOutput.php:1583
ParserOutput\addExtraCSPScriptSrc
addExtraCSPScriptSrc( $src)
Add an extra value to Content-Security-Policy script-src directive.
Definition: ParserOutput.php:1396
ParserOutput\setLimitReportData
setLimitReportData( $key, $value)
Sets parser limit report data for a key.
Definition: ParserOutput.php:1303
wfSetVar
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
Definition: GlobalFunctions.php:1543
ParserOutput\merge2D
static merge2D(array $a, array $b)
Definition: ParserOutput.php:1595
ParserOutput\addWrapperDivClass
addWrapperDivClass( $class)
Add a CSS class to use for the wrapping div.
Definition: ParserOutput.php:449
ParserOutput\$mLimitReportJSData
array $mLimitReportJSData
Parser limit report data for JSON.
Definition: ParserOutput.php:203
ParserOutput\$mModules
array $mModules
Modules to be loaded by ResourceLoader.
Definition: ParserOutput.php:134
ParserOutput\__sleep
__sleep()
Definition: ParserOutput.php:1425
ParserOutput\setNewSection
setNewSection( $value)
Definition: ParserOutput.php:769
ParserOutput\getModules
getModules()
Definition: ParserOutput.php:623
ParserOutput\$mAccessedOptions
true[] $mAccessedOptions
List of ParserOptions (stored in the keys).
Definition: ParserOutput.php:190
ParserOutput\getImages
& getImages()
Definition: ParserOutput.php:599
ParserOutput\addModules
addModules( $modules)
Definition: ParserOutput.php:921
ParserOutput\MIN_AR_TTL
const MIN_AR_TTL
Definition: ParserOutput.php:270
ParserOutput\$mLinksSpecial
array $mLinksSpecial
Keys are DBKs for the links to special pages in the document.
Definition: ParserOutput.php:76
ParserOutput\$mOutputHooks
array $mOutputHooks
Hook tags as per $wgParserOutputHooks.
Definition: ParserOutput.php:149
ParserOutput\setIndicator
setIndicator( $id, $content)
Definition: ParserOutput.php:742
ParserOutput\addTemplate
addTemplate( $title, $page_id, $rev_id)
Register a template dependency for this output.
Definition: ParserOutput.php:874
ParserOutput\getJsConfigVars
getJsConfigVars()
Definition: ParserOutput.php:635
wfUrlencode
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
Definition: GlobalFunctions.php:308
ParserOutput\mergeTrackingMetaDataFrom
mergeTrackingMetaDataFrom(ParserOutput $source)
Merges dependency tracking metadata such as backlinks, images used, and extension data from $source i...
Definition: ParserOutput.php:1553
ParserOutput\addExtraCSPStyleSrc
addExtraCSPStyleSrc( $src)
Add an extra value to Content-Security-Policy style-src directive.
Definition: ParserOutput.php:1384
OutputPage\getModuleStyles
getModuleStyles( $filter=false, $position=null)
Get the list of style-only modules to load on this page.
Definition: OutputPage.php:570
NS_FILE
const NS_FILE
Definition: Defines.php:75
ParserOutput\unsetProperty
unsetProperty( $name)
Definition: ParserOutput.php:1141
ParserOutput\setFlag
setFlag( $flag)
Attach a flag to the output so that it can be checked later to handle special cases.
Definition: ParserOutput.php:1045
ParserOutput\hideNewSection
hideNewSection( $value)
Definition: ParserOutput.php:773
ParserOutput\addLink
addLink(Title $title, $id=null)
Record a local or interwiki inline link for saving in future link tables.
Definition: ParserOutput.php:826
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1219
ParserOutput\$mMaxAdaptiveExpiry
int $mMaxAdaptiveExpiry
Upper bound of expiry based on parse duration.
Definition: ParserOutput.php:258
$s
$s
Definition: mergeMessageFileList.php:185
ParserOutput\__construct
__construct( $text='', $languageLinks=[], $categoryLinks=[], $unused=false, $titletext='')
Definition: ParserOutput.php:281
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1086
ParserOutput\EDITSECTION_REGEX
const EDITSECTION_REGEX
Definition: ParserOutput.php:260
ParserOutput\PARSE_SLOW_SEC
const PARSE_SLOW_SEC
Definition: ParserOutput.php:267
ParserOutput\getHeadItems
getHeadItems()
Definition: ParserOutput.php:619
ParserOutput\PARSE_FAST_SEC
const PARSE_FAST_SEC
Definition: ParserOutput.php:266
ParserOutput\setSpeculativePageIdUsed
setSpeculativePageIdUsed( $id)
Definition: ParserOutput.php:492
ParserOutput\getProperties
getProperties()
Definition: ParserOutput.php:1145
ParserOutput\mergeList
static mergeList(array $a, array $b)
Definition: ParserOutput.php:1587
ParserOutput\$mProperties
array $mProperties
Name/value pairs to be cached in the DB.
Definition: ParserOutput.php:165
ParserOutput\getModuleStyles
getModuleStyles()
Definition: ParserOutput.php:627
ParserOutput\$mHeadItems
array $mHeadItems
Items to put in the <head> section.
Definition: ParserOutput.php:129
ParserOutput\$mTimestamp
string $mTimestamp
Timestamp of the revision.
Definition: ParserOutput.php:175
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:58
ParserOutput\getExtraCSPDefaultSrcs
getExtraCSPDefaultSrcs()
Get extra Content-Security-Policy 'default-src' directives.
Definition: ParserOutput.php:679
ParserOutput\addExtraCSPDefaultSrc
addExtraCSPDefaultSrc( $src)
Add an extra value to Content-Security-Policy default-src directive.
Definition: ParserOutput.php:1374
ParserOutput\getLimitReportJSData
getLimitReportJSData()
Definition: ParserOutput.php:666
MWException
MediaWiki exception.
Definition: MWException.php:29
Parser\TOC_START
const TOC_START
Definition: Parser.php:148
OutputPage\getModules
getModules( $filter=false, $position=null, $param='mModules', $type=ResourceLoaderModule::TYPE_COMBINED)
Get the list of modules to include on this page.
Definition: OutputPage.php:545
ParserOutput\getCategoryLinks
getCategoryLinks()
Definition: ParserOutput.php:555
ParserOutput\setRevisionUsedSha1Base36
setRevisionUsedSha1Base36( $hash)
Definition: ParserOutput.php:524
ParserOutput\$mLinks
int[][] $mLinks
2-D map of NS/DBK to ID for the links in the document.
Definition: ParserOutput.php:70
ParserOutput\getFlag
getFlag( $flag)
Definition: ParserOutput.php:1053
ParserOutput\getTimestamp
getTimestamp()
Definition: ParserOutput.php:658
ParserOutput\isLinkInternal
static isLinkInternal( $internal, $url)
Checks, if a url is pointing to the own server.
Definition: ParserOutput.php:792
ParserOutput\addExternalLink
addExternalLink( $url)
Definition: ParserOutput.php:803
ParserOutput\$mExtraDefaultSrcs
array $mExtraDefaultSrcs
Extra default-src for CSP [Everything but script and style].
Definition: ParserOutput.php:223
ParserOutput\getInterwikiLinks
getInterwikiLinks()
Definition: ParserOutput.php:551
ParserOutput\$mLimitReportData
array $mLimitReportData
Parser limit report data.
Definition: ParserOutput.php:200
ParserOutput\mergeHtmlMetaDataFrom
mergeHtmlMetaDataFrom(ParserOutput $source)
Merges HTML metadata such as head items, JS config vars, and HTTP cache control info from $source int...
Definition: ParserOutput.php:1484
ParserOutput\updateRuntimeAdaptiveExpiry
updateRuntimeAdaptiveExpiry( $ttl)
Lower the runtime adaptive TTL to at most this value.
Definition: ParserOutput.php:1360
ParserOutput\getTimeSinceStart
getTimeSinceStart( $clock)
Returns the time since resetParseStartTime() was last called.
Definition: ParserOutput.php:1275
$modules
$modules
Definition: HTMLFormElement.php:15
ParserOutput\addImage
addImage( $name, $timestamp=null, $sha1=null)
Register a file dependency for this output.
Definition: ParserOutput.php:861
ParserOutput\$mHideNewSection
bool $mHideNewSection
Hide the new section link?
Definition: ParserOutput.php:119
ParserOutput\$mTemplates
array $mTemplates
2-D map of NS/DBK to ID for the template references.
Definition: ParserOutput.php:82
ParserOutput\$mNewSection
bool $mNewSection
Show a new section link?
Definition: ParserOutput.php:114
$wgParserCacheExpireTime
$wgParserCacheExpireTime
The expiry time for the parser cache, in seconds.
Definition: DefaultSettings.php:2654
ParserOutput\getTimes
static getTimes( $clock=null)
Definition: ParserOutput.php:1243
ParserOutput\addCategory
addCategory( $c, $sort)
Definition: ParserOutput.php:733
ParserOutput\useMaxValue
static useMaxValue( $a, $b)
Definition: ParserOutput.php:1641
Parser\TOC_END
const TOC_END
Definition: Parser.php:149
$title
$title
Definition: testCompression.php:38
ParserOutput\SUPPORTS_STATELESS_TRANSFORMS
const SUPPORTS_STATELESS_TRANSFORMS
Feature flags to indicate to extensions that MediaWiki core supports and uses getText() stateless tra...
Definition: ParserOutput.php:32
ParserOutput\addModuleStyles
addModuleStyles( $modules)
Definition: ParserOutput.php:929
ParserOutput\mergeInternalMetaDataFrom
mergeInternalMetaDataFrom(ParserOutput $source)
Merges internal metadata such as flags, accessed options, and profiling info from $source into this P...
Definition: ParserOutput.php:1448
ParserOutput\setText
setText( $text)
Definition: ParserOutput.php:701
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:83
ParserOutput\$mModuleStyles
array $mModuleStyles
Modules of which only the CSSS will be loaded by ResourceLoader.
Definition: ParserOutput.php:139
ParserOutput\getDisplayTitle
getDisplayTitle()
Get the title to be used for display.
Definition: ParserOutput.php:1032
ParserOutput\$mFlags
array $mFlags
Generic flags.
Definition: ParserOutput.php:233
ParserOutput\getIndicators
getIndicators()
Definition: ParserOutput.php:567
ParserOutput\setLanguageLinks
setLanguageLinks( $ll)
Definition: ParserOutput.php:705
ParserOutput\getSpeculativePageIdUsed
getSpeculativePageIdUsed()
Definition: ParserOutput.php:500
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:909
OutputPage
This is one of the Core classes and should be read at least once by any new developers.
Definition: OutputPage.php:47
ParserOutput\getLanguageLinks
& getLanguageLinks()
Definition: ParserOutput.php:547
ParserOutput\$mPreventClickjacking
bool $mPreventClickjacking
Whether to emit X-Frame-Options: DENY.
Definition: ParserOutput.php:213
ParserOutput\getLinksSpecial
& getLinksSpecial()
Definition: ParserOutput.php:587
ParserOutput\getExternalLinks
& getExternalLinks()
Definition: ParserOutput.php:607
ParserOutput\getTemplateIds
& getTemplateIds()
Definition: ParserOutput.php:595
OutputPage\getPreventClickjacking
getPreventClickjacking()
Get the prevent-clickjacking flag.
Definition: OutputPage.php:2361
ParserOutput\getTOCHTML
getTOCHTML()
Definition: ParserOutput.php:651
ParserOutput\recordOption
recordOption( $option)
Tags a parser option for use in the cache key for this parser output.
Definition: ParserOutput.php:1176
ParserOutput\addOutputHook
addOutputHook( $hook, $data=false)
Definition: ParserOutput.php:765
ParserOutput\getExtraCSPScriptSrcs
getExtraCSPScriptSrcs()
Get extra Content-Security-Policy 'script-src' directives.
Definition: ParserOutput.php:688
ParserOutput\SLOW_AR_TTL
const SLOW_AR_TTL
Definition: ParserOutput.php:269
ParserOutput\getTitleText
getTitleText()
Definition: ParserOutput.php:571
ParserOutput\clearWrapperDivClass
clearWrapperDivClass()
Clears the CSS class to use for the wrapping div, effectively disabling the wrapper div until addWrap...
Definition: ParserOutput.php:457
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:618
ParserOutput\setProperty
setProperty( $name, $value)
Set a property to be stored in the page_props database table.
Definition: ParserOutput.php:1125
ParserOutput\getNewSection
getNewSection()
Definition: ParserOutput.php:781
$content
$content
Definition: router.php:76
ParserOutput\setExtensionData
setExtensionData( $key, $value)
Attaches arbitrary data to this ParserObject.
Definition: ParserOutput.php:1220
ParserOutput\$mExtensionData
array $mExtensionData
extra data used by extensions.
Definition: ParserOutput.php:195
OutputPage\getHeadItemsArray
getHeadItemsArray()
Get an array of head items.
Definition: OutputPage.php:652
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:57
ParserOutput\getOutputHooks
getOutputHooks()
Definition: ParserOutput.php:639
ParserOutput\$speculativePageIdUsed
int null $speculativePageIdUsed
Assumed page ID for {{PAGEID}} if no revision is set.
Definition: ParserOutput.php:245
ParserOutput\getHideNewSection
getHideNewSection()
Definition: ParserOutput.php:777
$wgServer
$wgServer
URL of the server.
Definition: DefaultSettings.php:111
Hooks\runner
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Definition: Hooks.php:172
ParserOutput\$revisionUsedSha1Base36
string null $revisionUsedSha1Base36
SHA-1 base 36 hash of any self-transclusion.
Definition: ParserOutput.php:250
ParserOutput\$mExtraStyleSrcs
array $mExtraStyleSrcs
Extra style-src for CSP.
Definition: ParserOutput.php:228
ParserOutput\getRevisionUsedSha1Base36
getRevisionUsedSha1Base36()
Definition: ParserOutput.php:543
ParserOutput\$mExtraScriptSrcs
array $mExtraScriptSrcs
Extra script-src for CSP.
Definition: ParserOutput.php:218
ParserOutput\getNoGallery
getNoGallery()
Definition: ParserOutput.php:615
ParserOutput\addWarning
addWarning( $s)
Definition: ParserOutput.php:761
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:453
ParserOutput\$mTemplateIds
array $mTemplateIds
2-D map of NS/DBK to rev ID for the template references.
Definition: ParserOutput.php:88
ParserOutput\getTemplates
& getTemplates()
Definition: ParserOutput.php:591
ParserOutput\setSections
setSections( $toc)
Definition: ParserOutput.php:717
ParserOutput\setCategoryLinks
setCategoryLinks( $cl)
Definition: ParserOutput.php:709
ParserOutput\$mParseStartTime
array $mParseStartTime
Timestamps for getTimeSinceStart().
Definition: ParserOutput.php:208
ParserOutput\getRevisionTimestampUsed
getRevisionTimestampUsed()
Definition: ParserOutput.php:516
ParserOutput\getFileSearchOptions
& getFileSearchOptions()
Definition: ParserOutput.php:603
Title
Represents a title within MediaWiki.
Definition: Title.php:42
ParserOutput\$mTOCHTML
string $mTOCHTML
HTML of the TOC.
Definition: ParserOutput.php:170
ParserOutput\getProperty
getProperty( $name)
Definition: ParserOutput.php:1137
Parser\normalizeLinkUrl
static normalizeLinkUrl( $url)
Replace unusual escape codes in a URL with their equivalent characters.
Definition: Parser.php:2242
ParserOutput\$mExternalLinks
array $mExternalLinks
External link URLs, in the key only.
Definition: ParserOutput.php:103
ParserOutput\$mIndicators
array $mIndicators
Page status indicators, usually displayed in top-right corner.
Definition: ParserOutput.php:58
ParserOutput\FAST_AR_TTL
const FAST_AR_TTL
Definition: ParserOutput.php:268
ParserOutput\addJsConfigVars
addJsConfigVars( $keys, $value=null)
Add one or more variables to be set in mw.config in JavaScript.
Definition: ParserOutput.php:940
ParserOutput\getCategories
& getCategories()
Definition: ParserOutput.php:559
ParserOutput\hasText
hasText()
Returns true if text was passed to the constructor, or set using setText().
Definition: ParserOutput.php:300
ParserOutput\$mNoGallery
bool $mNoGallery
No gallery on category page? (NOGALLERY).
Definition: ParserOutput.php:124
ParserOutput\getRawText
getRawText()
Get the cacheable text with <mw:editsection> markers still in it.
Definition: ParserOutput.php:312
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
ParserOutput\useMinValue
static useMinValue( $a, $b)
Definition: ParserOutput.php:1629
ParserOutput\$mIndexPolicy
string $mIndexPolicy
'index' or 'noindex'? Any other value will result in no change.
Definition: ParserOutput.php:185
$keys
$keys
Definition: testCompression.php:72
ParserOutput\getLimitReportData
getLimitReportData()
Definition: ParserOutput.php:662
CacheTime\updateCacheExpiry
updateCacheExpiry( $seconds)
Sets the number of seconds after which this object should expire.
Definition: CacheTime.php:112
ParserOutput\addTrackingCategory
addTrackingCategory( $msg, $title)
Add a tracking category, getting the title from a system message, or print a debug message if the tit...
Definition: ParserOutput.php:981
$source
$source
Definition: mwdoc-filter.php:34
ParserOutput\useEachMinValue
static useEachMinValue(array $a, array $b)
Definition: ParserOutput.php:1614
ParserOutput\getExtensionData
getExtensionData( $key)
Gets extensions data previously attached to this ParserOutput using setExtensionData().
Definition: ParserOutput.php:1239
ParserOutput\addLanguageLink
addLanguageLink( $t)
Definition: ParserOutput.php:757
ParserOutput\$mInterwikiLinks
array $mInterwikiLinks
2-D map of prefix/DBK (in keys only) for the inline interwiki links in the document.
Definition: ParserOutput.php:109
Sanitizer\decodeTagAttributes
static decodeTagAttributes( $text)
Return an associative array of attribute names and values from a partial tag string.
Definition: Sanitizer.php:1248
ParserOutput\getText
getText( $options=[])
Get the output HTML.
Definition: ParserOutput.php:346
ParserOutput\setRevisionTimestampUsed
setRevisionTimestampUsed( $timestamp)
Definition: ParserOutput.php:508
$t
$t
Definition: testCompression.php:74
Sanitizer\decodeCharReferences
static decodeCharReferences( $text)
Decode any character references, numeric or named entities, in the text and return a UTF-8 string.
Definition: Sanitizer.php:1467
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
ParserOutput\$revisionTimestampUsed
int null $revisionTimestampUsed
Assumed rev timestamp for {{REVISIONTIMESTAMP}} if no revision is set.
Definition: ParserOutput.php:247
ParserOutput\$mSections
array $mSections
Table of contents.
Definition: ParserOutput.php:160
ParserOutput\$mText
string null $mText
The output text.
Definition: ParserOutput.php:42
ParserOutput\addInterwikiLink
addInterwikiLink( $title)
Definition: ParserOutput.php:891
ParserOutput\setTOCHTML
setTOCHTML( $tochtml)
Definition: ParserOutput.php:725
ParserOutput\$mTitleText
string $mTitleText
Title text of the chosen language variant, as HTML.
Definition: ParserOutput.php:63
OutputPage\getJsConfigVars
getJsConfigVars()
Get the javascript config vars to include on this page.
Definition: OutputPage.php:3217
$wgRegisterInternalExternals
$wgRegisterInternalExternals
By default MediaWiki does not register links pointing to same server in externallinks dataset,...
Definition: DefaultSettings.php:9012
ParserOutput\getSections
getSections()
Definition: ParserOutput.php:575
ParserOutput\$mSpeculativeRevId
int null $mSpeculativeRevId
Assumed rev ID for {{REVISIONID}} if no revision is set.
Definition: ParserOutput.php:235
ParserOutput\hasDynamicContent
hasDynamicContent()
Check whether the cache TTL was lowered due to dynamic content.
Definition: ParserOutput.php:1337
ParserOutput\addHeadItem
addHeadItem( $section, $tag=false)
Add some text to the "<head>".
Definition: ParserOutput.php:909
ParserOutput\setEnableOOUI
setEnableOOUI( $enable=false)
Enables OOUI, if true, in any OutputPage instance this ParserOutput object is added to.
Definition: ParserOutput.php:753
ParserOutput\$mCategories
array $mCategories
Map of category names to sort keys.
Definition: ParserOutput.php:53
ParserOutput\finalizeAdaptiveCacheExpiry
finalizeAdaptiveCacheExpiry()
Call this when parsing is done to lower the TTL based on low parse times.
Definition: ParserOutput.php:1405
ParserOutput\getSpeculativeRevIdUsed
getSpeculativeRevIdUsed()
Definition: ParserOutput.php:484
ParserOutput\getLinks
& getLinks()
Definition: ParserOutput.php:579
ParserOutput\setIndexPolicy
setIndexPolicy( $policy)
Definition: ParserOutput.php:721
ParserOutput\setNoGallery
setNoGallery( $value)
Definition: ParserOutput.php:611
ParserOutput\getAllFlags
getAllFlags()
Definition: ParserOutput.php:1061
ParserOutput\getIndexPolicy
getIndexPolicy()
Definition: ParserOutput.php:647
ParserOutput\getExtraCSPStyleSrcs
getExtraCSPStyleSrcs()
Get extra Content-Security-Policy 'style-src' directives.
Definition: ParserOutput.php:697
ParserOutput\getWrapperDivClass
getWrapperDivClass()
Returns the class (or classes) to be used with the wrapper div for this otuput.
Definition: ParserOutput.php:468
ParserOutput\preventClickjacking
preventClickjacking( $flag=null)
Get or set the prevent-clickjacking flag.
Definition: ParserOutput.php:1350
ParserOutput\getWarnings
getWarnings()
Definition: ParserOutput.php:643