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 $mTemplates = [];
77 
82  public $mTemplateIds = [];
83 
87  public $mImages = [];
88 
92  public $mFileSearchOptions = [];
93 
97  public $mExternalLinks = [];
98 
103  public $mInterwikiLinks = [];
104 
108  public $mNewSection = false;
109 
113  public $mHideNewSection = false;
114 
118  public $mNoGallery = false;
119 
123  public $mHeadItems = [];
124 
128  public $mModules = [];
129 
133  public $mModuleStyles = [];
134 
138  public $mJsConfigVars = [];
139 
143  public $mOutputHooks = [];
144 
149  public $mWarnings = [];
150 
154  public $mSections = [];
155 
159  public $mProperties = [];
160 
164  public $mTOCHTML = '';
165 
169  public $mTimestamp;
170 
174  public $mEnableOOUI = false;
175 
179  private $mIndexPolicy = '';
180 
184  private $mAccessedOptions = [];
185 
189  private $mExtensionData = [];
190 
194  private $mLimitReportData = [];
195 
197  private $mLimitReportJSData = [];
198 
202  private $mParseStartTime = [];
203 
207  private $mPreventClickjacking = false;
208 
212  private $mExtraScriptSrcs = [];
213 
217  private $mExtraDefaultSrcs = [];
218 
222  private $mExtraStyleSrcs = [];
223 
227  private $mFlags = [];
228 
230  private const SPECULATIVE_FIELDS = [
231  'speculativePageIdUsed',
232  'mSpeculativeRevId',
233  'revisionTimestampUsed'
234  ];
235 
237  private $mSpeculativeRevId;
242 
245 
249  private $mWrapperDivClasses = [];
250 
252  private $mMaxAdaptiveExpiry = INF;
253 
254  private const EDITSECTION_REGEX =
255  '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#s';
256 
257  // finalizeAdaptiveCacheExpiry() uses TTL = MAX( m * PARSE_TIME + b, MIN_AR_TTL)
258  // Current values imply that m=3933.333333 and b=-333.333333
259  // See https://www.nngroup.com/articles/website-response-times/
260  private const PARSE_FAST_SEC = 0.100; // perceived "fast" page parse
261  private const PARSE_SLOW_SEC = 1.0; // perceived "slow" page parse
262  private const FAST_AR_TTL = 60; // adaptive TTL for "fast" pages
263  private const SLOW_AR_TTL = 3600; // adaptive TTL for "slow" pages
264  private const MIN_AR_TTL = 15; // min adaptive TTL (for sanity, pool counter, and edit stashing)
265 
275  public function __construct( $text = '', $languageLinks = [], $categoryLinks = [],
276  $unused = false, $titletext = ''
277  ) {
278  $this->mText = $text;
279  $this->mLanguageLinks = $languageLinks;
280  $this->mCategories = $categoryLinks;
281  $this->mTitleText = $titletext;
282  }
283 
294  public function hasText() {
295  return ( $this->mText !== null );
296  }
297 
306  public function getRawText() {
307  if ( $this->mText === null ) {
308  throw new LogicException( 'This ParserOutput contains no text!' );
309  }
310 
311  return $this->mText;
312  }
313 
340  public function getText( $options = [] ) {
341  $options += [
342  'allowTOC' => true,
343  'enableSectionEditLinks' => true,
344  'skin' => null,
345  'unwrap' => false,
346  'deduplicateStyles' => true,
347  'wrapperDivClass' => $this->getWrapperDivClass(),
348  ];
349  $text = $this->getRawText();
350 
351  Hooks::runWithoutAbort( 'ParserOutputPostCacheTransform', [ $this, &$text, &$options ] );
352 
353  if ( $options['wrapperDivClass'] !== '' && !$options['unwrap'] ) {
354  $text = Html::rawElement( 'div', [ 'class' => $options['wrapperDivClass'] ], $text );
355  }
356 
357  if ( $options['enableSectionEditLinks'] ) {
358  // TODO: Passing the skin should be required
359  $skin = $options['skin'] ?: RequestContext::getMain()->getSkin();
360 
361  $text = preg_replace_callback(
362  self::EDITSECTION_REGEX,
363  function ( $m ) use ( $skin ) {
364  $editsectionPage = Title::newFromText( htmlspecialchars_decode( $m[1] ) );
365  $editsectionSection = htmlspecialchars_decode( $m[2] );
366  $editsectionContent = isset( $m[4] ) ? Sanitizer::decodeCharReferences( $m[3] ) : null;
367 
368  if ( !is_object( $editsectionPage ) ) {
369  throw new MWException( "Bad parser output text." );
370  }
371 
372  return $skin->doEditSectionLink(
373  $editsectionPage,
374  $editsectionSection,
375  $editsectionContent,
376  $skin->getLanguage()
377  );
378  },
379  $text
380  );
381  } else {
382  $text = preg_replace( self::EDITSECTION_REGEX, '', $text );
383  }
384 
385  if ( $options['allowTOC'] ) {
386  $text = str_replace( [ Parser::TOC_START, Parser::TOC_END ], '', $text );
387  } else {
388  $text = preg_replace(
389  '#' . preg_quote( Parser::TOC_START, '#' ) . '.*?' . preg_quote( Parser::TOC_END, '#' ) . '#s',
390  '',
391  $text
392  );
393  }
394 
395  if ( $options['deduplicateStyles'] ) {
396  $seen = [];
397  $text = preg_replace_callback(
398  '#<style\s+([^>]*data-mw-deduplicate\s*=[^>]*)>.*?</style>#s',
399  function ( $m ) use ( &$seen ) {
400  $attr = Sanitizer::decodeTagAttributes( $m[1] );
401  if ( !isset( $attr['data-mw-deduplicate'] ) ) {
402  return $m[0];
403  }
404 
405  $key = $attr['data-mw-deduplicate'];
406  if ( !isset( $seen[$key] ) ) {
407  $seen[$key] = true;
408  return $m[0];
409  }
410 
411  // We were going to use an empty <style> here, but there
412  // was concern that would be too much overhead for browsers.
413  // So let's hope a <link> with a non-standard rel and href isn't
414  // going to be misinterpreted or mangled by any subsequent processing.
415  return Html::element( 'link', [
416  'rel' => 'mw-deduplicated-inline-style',
417  'href' => "mw-data:" . wfUrlencode( $key ),
418  ] );
419  },
420  $text
421  );
422  }
423 
424  // Hydrate slot section header placeholders generated by RevisionRenderer.
425  $text = preg_replace_callback(
426  '#<mw:slotheader>(.*?)</mw:slotheader>#',
427  function ( $m ) {
428  $role = htmlspecialchars_decode( $m[1] );
429  // TODO: map to message, using the interface language. Set lang="xyz" accordingly.
430  $headerText = $role;
431  return $headerText;
432  },
433  $text
434  );
435  return $text;
436  }
437 
443  public function addWrapperDivClass( $class ) {
444  $this->mWrapperDivClasses[$class] = true;
445  }
446 
451  public function clearWrapperDivClass() {
452  $this->mWrapperDivClasses = [];
453  }
454 
462  public function getWrapperDivClass() {
463  return implode( ' ', array_keys( $this->mWrapperDivClasses ) );
464  }
465 
470  public function setSpeculativeRevIdUsed( $id ) {
471  $this->mSpeculativeRevId = $id;
472  }
473 
478  public function getSpeculativeRevIdUsed() {
480  }
481 
486  public function setSpeculativePageIdUsed( $id ) {
487  $this->speculativePageIdUsed = $id;
488  }
489 
494  public function getSpeculativePageIdUsed() {
496  }
497 
502  public function setRevisionTimestampUsed( $timestamp ) {
503  $this->revisionTimestampUsed = $timestamp;
504  }
505 
510  public function getRevisionTimestampUsed() {
512  }
513 
518  public function setRevisionUsedSha1Base36( $hash ) {
519  if ( $hash === null ) {
520  return; // e.g. RevisionRecord::getSha1() returned null
521  }
522 
523  if (
524  $this->revisionUsedSha1Base36 !== null &&
525  $this->revisionUsedSha1Base36 !== $hash
526  ) {
527  $this->revisionUsedSha1Base36 = ''; // mismatched
528  } else {
529  $this->revisionUsedSha1Base36 = $hash;
530  }
531  }
532 
537  public function getRevisionUsedSha1Base36() {
539  }
540 
541  public function &getLanguageLinks() {
542  return $this->mLanguageLinks;
543  }
544 
545  public function getInterwikiLinks() {
546  return $this->mInterwikiLinks;
547  }
548 
549  public function getCategoryLinks() {
550  return array_keys( $this->mCategories );
551  }
552 
553  public function &getCategories() {
554  return $this->mCategories;
555  }
556 
561  public function getIndicators() {
562  return $this->mIndicators;
563  }
564 
565  public function getTitleText() {
566  return $this->mTitleText;
567  }
568 
569  public function getSections() {
570  return $this->mSections;
571  }
572 
573  public function &getLinks() {
574  return $this->mLinks;
575  }
576 
577  public function &getTemplates() {
578  return $this->mTemplates;
579  }
580 
581  public function &getTemplateIds() {
582  return $this->mTemplateIds;
583  }
584 
585  public function &getImages() {
586  return $this->mImages;
587  }
588 
589  public function &getFileSearchOptions() {
591  }
592 
593  public function &getExternalLinks() {
594  return $this->mExternalLinks;
595  }
596 
597  public function setNoGallery( $value ) {
598  $this->mNoGallery = (bool)$value;
599  }
600 
601  public function getNoGallery() {
602  return $this->mNoGallery;
603  }
604 
605  public function getHeadItems() {
606  return $this->mHeadItems;
607  }
608 
609  public function getModules() {
610  return $this->mModules;
611  }
612 
613  public function getModuleStyles() {
614  return $this->mModuleStyles;
615  }
616 
621  public function getJsConfigVars() {
622  return $this->mJsConfigVars;
623  }
624 
625  public function getOutputHooks() {
626  return (array)$this->mOutputHooks;
627  }
628 
629  public function getWarnings() {
630  return array_keys( $this->mWarnings );
631  }
632 
633  public function getIndexPolicy() {
634  return $this->mIndexPolicy;
635  }
636 
637  public function getTOCHTML() {
638  return $this->mTOCHTML;
639  }
640 
644  public function getTimestamp() {
645  return $this->mTimestamp;
646  }
647 
648  public function getLimitReportData() {
650  }
651 
652  public function getLimitReportJSData() {
654  }
655 
656  public function getEnableOOUI() {
657  return $this->mEnableOOUI;
658  }
659 
665  public function getExtraCSPDefaultSrcs() {
667  }
668 
674  public function getExtraCSPScriptSrcs() {
676  }
677 
683  public function getExtraCSPStyleSrcs() {
684  return $this->mExtraStyleSrcs;
685  }
686 
687  public function setText( $text ) {
688  return wfSetVar( $this->mText, $text );
689  }
690 
691  public function setLanguageLinks( $ll ) {
692  return wfSetVar( $this->mLanguageLinks, $ll );
693  }
694 
695  public function setCategoryLinks( $cl ) {
696  return wfSetVar( $this->mCategories, $cl );
697  }
698 
699  public function setTitleText( $t ) {
700  return wfSetVar( $this->mTitleText, $t );
701  }
702 
703  public function setSections( $toc ) {
704  return wfSetVar( $this->mSections, $toc );
705  }
706 
707  public function setIndexPolicy( $policy ) {
708  return wfSetVar( $this->mIndexPolicy, $policy );
709  }
710 
711  public function setTOCHTML( $tochtml ) {
712  return wfSetVar( $this->mTOCHTML, $tochtml );
713  }
714 
715  public function setTimestamp( $timestamp ) {
716  return wfSetVar( $this->mTimestamp, $timestamp );
717  }
718 
719  public function addCategory( $c, $sort ) {
720  $this->mCategories[$c] = $sort;
721  }
722 
728  public function setIndicator( $id, $content ) {
729  $this->mIndicators[$id] = $content;
730  }
731 
739  public function setEnableOOUI( $enable = false ) {
740  $this->mEnableOOUI = $enable;
741  }
742 
743  public function addLanguageLink( $t ) {
744  $this->mLanguageLinks[] = $t;
745  }
746 
747  public function addWarning( $s ) {
748  $this->mWarnings[$s] = 1;
749  }
750 
751  public function addOutputHook( $hook, $data = false ) {
752  $this->mOutputHooks[] = [ $hook, $data ];
753  }
754 
755  public function setNewSection( $value ) {
756  $this->mNewSection = (bool)$value;
757  }
758 
759  public function hideNewSection( $value ) {
760  $this->mHideNewSection = (bool)$value;
761  }
762 
763  public function getHideNewSection() {
764  return (bool)$this->mHideNewSection;
765  }
766 
767  public function getNewSection() {
768  return (bool)$this->mNewSection;
769  }
770 
778  public static function isLinkInternal( $internal, $url ) {
779  return (bool)preg_match( '/^' .
780  # If server is proto relative, check also for http/https links
781  ( substr( $internal, 0, 2 ) === '//' ? '(?:https?:)?' : '' ) .
782  preg_quote( $internal, '/' ) .
783  # check for query/path/anchor or end of link in each case
784  '(?:[\?\/\#]|$)/i',
785  $url
786  );
787  }
788 
789  public function addExternalLink( $url ) {
790  # We don't register links pointing to our own server, unless... :-)
792 
793  # Replace unnecessary URL escape codes with the referenced character
794  # This prevents spammers from hiding links from the filters
795  $url = Parser::normalizeLinkUrl( $url );
796 
797  $registerExternalLink = true;
799  $registerExternalLink = !self::isLinkInternal( $wgServer, $url );
800  }
801  if ( $registerExternalLink ) {
802  $this->mExternalLinks[$url] = 1;
803  }
804  }
805 
812  public function addLink( Title $title, $id = null ) {
813  if ( $title->isExternal() ) {
814  // Don't record interwikis in pagelinks
815  $this->addInterwikiLink( $title );
816  return;
817  }
818  $ns = $title->getNamespace();
819  $dbk = $title->getDBkey();
820  if ( $ns == NS_MEDIA ) {
821  // Normalize this pseudo-alias if it makes it down here...
822  $ns = NS_FILE;
823  } elseif ( $ns == NS_SPECIAL ) {
824  // We don't record Special: links currently
825  // It might actually be wise to, but we'd need to do some normalization.
826  return;
827  } elseif ( $dbk === '' ) {
828  // Don't record self links - [[#Foo]]
829  return;
830  }
831  if ( !isset( $this->mLinks[$ns] ) ) {
832  $this->mLinks[$ns] = [];
833  }
834  if ( $id === null ) {
835  $id = $title->getArticleID();
836  }
837  $this->mLinks[$ns][$dbk] = $id;
838  }
839 
846  public function addImage( $name, $timestamp = null, $sha1 = null ) {
847  $this->mImages[$name] = 1;
848  if ( $timestamp !== null && $sha1 !== null ) {
849  $this->mFileSearchOptions[$name] = [ 'time' => $timestamp, 'sha1' => $sha1 ];
850  }
851  }
852 
859  public function addTemplate( $title, $page_id, $rev_id ) {
860  $ns = $title->getNamespace();
861  $dbk = $title->getDBkey();
862  if ( !isset( $this->mTemplates[$ns] ) ) {
863  $this->mTemplates[$ns] = [];
864  }
865  $this->mTemplates[$ns][$dbk] = $page_id;
866  if ( !isset( $this->mTemplateIds[$ns] ) ) {
867  $this->mTemplateIds[$ns] = [];
868  }
869  $this->mTemplateIds[$ns][$dbk] = $rev_id; // For versioning
870  }
871 
876  public function addInterwikiLink( $title ) {
877  if ( !$title->isExternal() ) {
878  throw new MWException( 'Non-interwiki link passed, internal parser error.' );
879  }
880  $prefix = $title->getInterwiki();
881  if ( !isset( $this->mInterwikiLinks[$prefix] ) ) {
882  $this->mInterwikiLinks[$prefix] = [];
883  }
884  $this->mInterwikiLinks[$prefix][$title->getDBkey()] = 1;
885  }
886 
894  public function addHeadItem( $section, $tag = false ) {
895  if ( $tag !== false ) {
896  $this->mHeadItems[$tag] = $section;
897  } else {
898  $this->mHeadItems[] = $section;
899  }
900  }
901 
906  public function addModules( $modules ) {
907  $this->mModules = array_merge( $this->mModules, (array)$modules );
908  }
909 
914  public function addModuleStyles( $modules ) {
915  $this->mModuleStyles = array_merge( $this->mModuleStyles, (array)$modules );
916  }
917 
925  public function addJsConfigVars( $keys, $value = null ) {
926  if ( is_array( $keys ) ) {
927  foreach ( $keys as $key => $value ) {
928  $this->mJsConfigVars[$key] = $value;
929  }
930  return;
931  }
932 
933  $this->mJsConfigVars[$keys] = $value;
934  }
935 
941  public function addOutputPageMetadata( OutputPage $out ) {
942  $this->addModules( $out->getModules() );
943  $this->addModuleStyles( $out->getModuleStyles() );
944  $this->addJsConfigVars( $out->getJsConfigVars() );
945 
946  $this->mHeadItems = array_merge( $this->mHeadItems, $out->getHeadItemsArray() );
947  $this->mPreventClickjacking = $this->mPreventClickjacking || $out->getPreventClickjacking();
948  }
949 
966  public function addTrackingCategory( $msg, $title ) {
967  if ( $title->isSpecialPage() ) {
968  wfDebug( __METHOD__ . ": Not adding tracking category $msg to special page!\n" );
969  return false;
970  }
971 
972  // Important to parse with correct title (T33469)
973  $cat = wfMessage( $msg )
974  ->title( $title )
975  ->inContentLanguage()
976  ->text();
977 
978  # Allow tracking categories to be disabled by setting them to "-"
979  if ( $cat === '-' ) {
980  return false;
981  }
982 
983  $containerCategory = Title::makeTitleSafe( NS_CATEGORY, $cat );
984  if ( $containerCategory ) {
985  $this->addCategory( $containerCategory->getDBkey(), $this->getProperty( 'defaultsort' ) ?: '' );
986  return true;
987  } else {
988  wfDebug( __METHOD__ . ": [[MediaWiki:$msg]] is not a valid title!\n" );
989  return false;
990  }
991  }
992 
1004  public function setDisplayTitle( $text ) {
1005  $this->setTitleText( $text );
1006  $this->setProperty( 'displaytitle', $text );
1007  }
1008 
1017  public function getDisplayTitle() {
1018  $t = $this->getTitleText();
1019  if ( $t === '' ) {
1020  return false;
1021  }
1022  return $t;
1023  }
1024 
1030  public function setFlag( $flag ) {
1031  $this->mFlags[$flag] = true;
1032  }
1033 
1038  public function getFlag( $flag ) {
1039  return isset( $this->mFlags[$flag] );
1040  }
1041 
1046  public function getAllFlags() {
1047  return array_keys( $this->mFlags );
1048  }
1049 
1110  public function setProperty( $name, $value ) {
1111  $this->mProperties[$name] = $value;
1112  }
1113 
1122  public function getProperty( $name ) {
1123  return $this->mProperties[$name] ?? false;
1124  }
1125 
1126  public function unsetProperty( $name ) {
1127  unset( $this->mProperties[$name] );
1128  }
1129 
1130  public function getProperties() {
1131  if ( !isset( $this->mProperties ) ) {
1132  $this->mProperties = [];
1133  }
1134  return $this->mProperties;
1135  }
1136 
1142  public function getUsedOptions() {
1143  if ( !isset( $this->mAccessedOptions ) ) {
1144  return [];
1145  }
1146  return array_keys( $this->mAccessedOptions );
1147  }
1148 
1161  public function recordOption( $option ) {
1162  $this->mAccessedOptions[$option] = true;
1163  }
1164 
1205  public function setExtensionData( $key, $value ) {
1206  if ( $value === null ) {
1207  unset( $this->mExtensionData[$key] );
1208  } else {
1209  $this->mExtensionData[$key] = $value;
1210  }
1211  }
1212 
1224  public function getExtensionData( $key ) {
1225  return $this->mExtensionData[$key] ?? null;
1226  }
1227 
1228  private static function getTimes( $clock = null ) {
1229  $ret = [];
1230  if ( !$clock || $clock === 'wall' ) {
1231  $ret['wall'] = microtime( true );
1232  }
1233  if ( !$clock || $clock === 'cpu' ) {
1234  $ru = getrusage( 0 /* RUSAGE_SELF */ );
1235  $ret['cpu'] = $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1e6;
1236  $ret['cpu'] += $ru['ru_stime.tv_sec'] + $ru['ru_stime.tv_usec'] / 1e6;
1237  }
1238  return $ret;
1239  }
1240 
1245  public function resetParseStartTime() {
1246  $this->mParseStartTime = self::getTimes();
1247  }
1248 
1260  public function getTimeSinceStart( $clock ) {
1261  if ( !isset( $this->mParseStartTime[$clock] ) ) {
1262  return null;
1263  }
1264 
1265  $end = self::getTimes( $clock );
1266  return $end[$clock] - $this->mParseStartTime[$clock];
1267  }
1268 
1288  public function setLimitReportData( $key, $value ) {
1289  $this->mLimitReportData[$key] = $value;
1290 
1291  if ( is_array( $value ) ) {
1292  if ( array_keys( $value ) === [ 0, 1 ]
1293  && is_numeric( $value[0] )
1294  && is_numeric( $value[1] )
1295  ) {
1296  $data = [ 'value' => $value[0], 'limit' => $value[1] ];
1297  } else {
1298  $data = $value;
1299  }
1300  } else {
1301  $data = $value;
1302  }
1303 
1304  if ( strpos( $key, '-' ) ) {
1305  list( $ns, $name ) = explode( '-', $key, 2 );
1306  $this->mLimitReportJSData[$ns][$name] = $data;
1307  } else {
1308  $this->mLimitReportJSData[$key] = $data;
1309  }
1310  }
1311 
1322  public function hasDynamicContent() {
1323  global $wgParserCacheExpireTime;
1324 
1325  return $this->getCacheExpiry() < $wgParserCacheExpireTime;
1326  }
1327 
1335  public function preventClickjacking( $flag = null ) {
1336  return wfSetVar( $this->mPreventClickjacking, $flag );
1337  }
1338 
1345  public function updateRuntimeAdaptiveExpiry( $ttl ) {
1346  $this->mMaxAdaptiveExpiry = min( $ttl, $this->mMaxAdaptiveExpiry );
1347  $this->updateCacheExpiry( $ttl );
1348  }
1349 
1359  public function addExtraCSPDefaultSrc( $src ) {
1360  $this->mExtraDefaultSrcs[] = $src;
1361  }
1362 
1369  public function addExtraCSPStyleSrc( $src ) {
1370  $this->mExtraStyleSrcs[] = $src;
1371  }
1372 
1381  public function addExtraCSPScriptSrc( $src ) {
1382  $this->mExtraScriptSrcs[] = $src;
1383  }
1384 
1390  public function finalizeAdaptiveCacheExpiry() {
1391  if ( is_infinite( $this->mMaxAdaptiveExpiry ) ) {
1392  return; // not set
1393  }
1394 
1395  $runtime = $this->getTimeSinceStart( 'wall' );
1396  if ( is_float( $runtime ) ) {
1397  $slope = ( self::SLOW_AR_TTL - self::FAST_AR_TTL )
1398  / ( self::PARSE_SLOW_SEC - self::PARSE_FAST_SEC );
1399  // SLOW_AR_TTL = PARSE_SLOW_SEC * $slope + $point
1400  $point = self::SLOW_AR_TTL - self::PARSE_SLOW_SEC * $slope;
1401 
1402  $adaptiveTTL = min(
1403  max( $slope * $runtime + $point, self::MIN_AR_TTL ),
1404  $this->mMaxAdaptiveExpiry
1405  );
1406  $this->updateCacheExpiry( $adaptiveTTL );
1407  }
1408  }
1409 
1410  public function __sleep() {
1411  return array_filter( array_keys( get_object_vars( $this ) ),
1412  function ( $field ) {
1413  if ( $field === 'mParseStartTime' ) {
1414  return false;
1415  } elseif ( strpos( $field, "\0" ) !== false ) {
1416  // Unserializing unknown private fields in HHVM causes
1417  // member variables with nulls in their names (T229366)
1418  return false;
1419  } else {
1420  return true;
1421  }
1422  }
1423  );
1424  }
1425 
1434  $this->mOutputHooks = self::mergeList( $this->mOutputHooks, $source->getOutputHooks() );
1435  $this->mWarnings = self::mergeMap( $this->mWarnings, $source->mWarnings ); // don't use getter
1436  $this->mTimestamp = $this->useMaxValue( $this->mTimestamp, $source->getTimestamp() );
1437 
1438  foreach ( self::SPECULATIVE_FIELDS as $field ) {
1439  if ( $this->$field && $source->$field && $this->$field !== $source->$field ) {
1440  wfLogWarning( __METHOD__ . ": inconsistent '$field' properties!" );
1441  }
1442  $this->$field = $this->useMaxValue( $this->$field, $source->$field );
1443  }
1444 
1445  $this->mParseStartTime = $this->useEachMinValue(
1446  $this->mParseStartTime,
1447  $source->mParseStartTime
1448  );
1449 
1450  $this->mFlags = self::mergeMap( $this->mFlags, $source->mFlags );
1451  $this->mAccessedOptions = self::mergeMap( $this->mAccessedOptions, $source->mAccessedOptions );
1452 
1453  // TODO: maintain per-slot limit reports!
1454  if ( empty( $this->mLimitReportData ) ) {
1455  $this->mLimitReportData = $source->mLimitReportData;
1456  }
1457  if ( empty( $this->mLimitReportJSData ) ) {
1458  $this->mLimitReportJSData = $source->mLimitReportJSData;
1459  }
1460  }
1461 
1470  // HTML and HTTP
1471  $this->mHeadItems = self::mergeMixedList( $this->mHeadItems, $source->getHeadItems() );
1472  $this->mModules = self::mergeList( $this->mModules, $source->getModules() );
1473  $this->mModuleStyles = self::mergeList( $this->mModuleStyles, $source->getModuleStyles() );
1474  $this->mJsConfigVars = self::mergeMap( $this->mJsConfigVars, $source->getJsConfigVars() );
1475  $this->mMaxAdaptiveExpiry = min( $this->mMaxAdaptiveExpiry, $source->mMaxAdaptiveExpiry );
1476  $this->mExtraStyleSrcs = self::mergeList(
1477  $this->mExtraStyleSrcs,
1478  $source->getExtraCSPStyleSrcs()
1479  );
1480  $this->mExtraScriptSrcs = self::mergeList(
1481  $this->mExtraScriptSrcs,
1482  $source->getExtraCSPScriptSrcs()
1483  );
1484  $this->mExtraDefaultSrcs = self::mergeList(
1485  $this->mExtraDefaultSrcs,
1486  $source->getExtraCSPDefaultSrcs()
1487  );
1488 
1489  // "noindex" always wins!
1490  if ( $this->mIndexPolicy === 'noindex' || $source->mIndexPolicy === 'noindex' ) {
1491  $this->mIndexPolicy = 'noindex';
1492  } elseif ( $this->mIndexPolicy !== 'index' ) {
1493  $this->mIndexPolicy = $source->mIndexPolicy;
1494  }
1495 
1496  // Skin control
1497  $this->mNewSection = $this->mNewSection || $source->getNewSection();
1498  $this->mHideNewSection = $this->mHideNewSection || $source->getHideNewSection();
1499  $this->mNoGallery = $this->mNoGallery || $source->getNoGallery();
1500  $this->mEnableOOUI = $this->mEnableOOUI || $source->getEnableOOUI();
1501  $this->mPreventClickjacking = $this->mPreventClickjacking || $source->preventClickjacking();
1502 
1503  // TODO: we'll have to be smarter about this!
1504  $this->mSections = array_merge( $this->mSections, $source->getSections() );
1505  $this->mTOCHTML .= $source->mTOCHTML;
1506 
1507  // XXX: we don't want to concatenate title text, so first write wins.
1508  // We should use the first *modified* title text, but we don't have the original to check.
1509  if ( $this->mTitleText === null || $this->mTitleText === '' ) {
1510  $this->mTitleText = $source->mTitleText;
1511  }
1512 
1513  // class names are stored in array keys
1514  $this->mWrapperDivClasses = self::mergeMap(
1515  $this->mWrapperDivClasses,
1516  $source->mWrapperDivClasses
1517  );
1518 
1519  // NOTE: last write wins, same as within one ParserOutput
1520  $this->mIndicators = self::mergeMap( $this->mIndicators, $source->getIndicators() );
1521 
1522  // NOTE: include extension data in "tracking meta data" as well as "html meta data"!
1523  // TODO: add a $mergeStrategy parameter to setExtensionData to allow different
1524  // kinds of extension data to be merged in different ways.
1525  $this->mExtensionData = self::mergeMap(
1526  $this->mExtensionData,
1527  $source->mExtensionData
1528  );
1529  }
1530 
1539  $this->mLanguageLinks = self::mergeList( $this->mLanguageLinks, $source->getLanguageLinks() );
1540  $this->mCategories = self::mergeMap( $this->mCategories, $source->getCategories() );
1541  $this->mLinks = self::merge2D( $this->mLinks, $source->getLinks() );
1542  $this->mTemplates = self::merge2D( $this->mTemplates, $source->getTemplates() );
1543  $this->mTemplateIds = self::merge2D( $this->mTemplateIds, $source->getTemplateIds() );
1544  $this->mImages = self::mergeMap( $this->mImages, $source->getImages() );
1545  $this->mFileSearchOptions = self::mergeMap(
1546  $this->mFileSearchOptions,
1547  $source->getFileSearchOptions()
1548  );
1549  $this->mExternalLinks = self::mergeMap( $this->mExternalLinks, $source->getExternalLinks() );
1550  $this->mInterwikiLinks = self::merge2D(
1551  $this->mInterwikiLinks,
1552  $source->getInterwikiLinks()
1553  );
1554 
1555  // TODO: add a $mergeStrategy parameter to setProperty to allow different
1556  // kinds of properties to be merged in different ways.
1557  $this->mProperties = self::mergeMap( $this->mProperties, $source->getProperties() );
1558 
1559  // NOTE: include extension data in "tracking meta data" as well as "html meta data"!
1560  // TODO: add a $mergeStrategy parameter to setExtensionData to allow different
1561  // kinds of extension data to be merged in different ways.
1562  $this->mExtensionData = self::mergeMap(
1563  $this->mExtensionData,
1564  $source->mExtensionData
1565  );
1566  }
1567 
1568  private static function mergeMixedList( array $a, array $b ) {
1569  return array_unique( array_merge( $a, $b ), SORT_REGULAR );
1570  }
1571 
1572  private static function mergeList( array $a, array $b ) {
1573  return array_values( array_unique( array_merge( $a, $b ), SORT_REGULAR ) );
1574  }
1575 
1576  private static function mergeMap( array $a, array $b ) {
1577  return array_replace( $a, $b );
1578  }
1579 
1580  private static function merge2D( array $a, array $b ) {
1581  $values = [];
1582  $keys = array_merge( array_keys( $a ), array_keys( $b ) );
1583 
1584  foreach ( $keys as $k ) {
1585  if ( empty( $a[$k] ) ) {
1586  $values[$k] = $b[$k];
1587  } elseif ( empty( $b[$k] ) ) {
1588  $values[$k] = $a[$k];
1589  } elseif ( is_array( $a[$k] ) && is_array( $b[$k] ) ) {
1590  $values[$k] = array_replace( $a[$k], $b[$k] );
1591  } else {
1592  $values[$k] = $b[$k];
1593  }
1594  }
1595 
1596  return $values;
1597  }
1598 
1599  private static function useEachMinValue( array $a, array $b ) {
1600  $values = [];
1601  $keys = array_merge( array_keys( $a ), array_keys( $b ) );
1602 
1603  foreach ( $keys as $k ) {
1604  if ( is_array( $a[$k] ?? null ) && is_array( $b[$k] ?? null ) ) {
1605  $values[$k] = self::useEachMinValue( $a[$k], $b[$k] );
1606  } else {
1607  $values[$k] = self::useMinValue( $a[$k] ?? null, $b[$k] ?? null );
1608  }
1609  }
1610 
1611  return $values;
1612  }
1613 
1614  private static function useMinValue( $a, $b ) {
1615  if ( $a === null ) {
1616  return $b;
1617  }
1618 
1619  if ( $b === null ) {
1620  return $a;
1621  }
1622 
1623  return min( $a, $b );
1624  }
1625 
1626  private static function useMaxValue( $a, $b ) {
1627  if ( $a === null ) {
1628  return $b;
1629  }
1630 
1631  if ( $b === null ) {
1632  return $a;
1633  }
1634 
1635  return max( $a, $b );
1636  }
1637 
1638 }
ParserOutput\$mImages
array $mImages
DB keys of the images used, in the array key only.
Definition: ParserOutput.php:87
ParserOutput\$mWrapperDivClasses
$mWrapperDivClasses
string CSS classes to use for the wrapping div, stored in the array keys.
Definition: ParserOutput.php:249
ParserOutput\addOutputPageMetadata
addOutputPageMetadata(OutputPage $out)
Copy items from the OutputPage object into this one.
Definition: ParserOutput.php:941
ParserOutput\getEnableOOUI
getEnableOOUI()
Definition: ParserOutput.php:656
ParserOutput\mergeMap
static mergeMap(array $a, array $b)
Definition: ParserOutput.php:1576
ParserOutput\$mEnableOOUI
bool $mEnableOOUI
Whether OOUI should be enabled.
Definition: ParserOutput.php:174
ParserOutput\$mWarnings
array $mWarnings
Warning text to be returned to the user.
Definition: ParserOutput.php:149
ParserOutput\$mJsConfigVars
array $mJsConfigVars
JavaScript config variable for mw.config combined with this page.
Definition: ParserOutput.php:138
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:92
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:332
ParserOutput\setTitleText
setTitleText( $t)
Definition: ParserOutput.php:699
ParserOutput
Definition: ParserOutput.php:25
ParserOutput\setSpeculativeRevIdUsed
setSpeculativeRevIdUsed( $id)
Definition: ParserOutput.php:470
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:1245
ParserOutput\setDisplayTitle
setDisplayTitle( $text)
Override the title to be used for display.
Definition: ParserOutput.php:1004
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:715
ParserOutput\getUsedOptions
getUsedOptions()
Returns the options from its ParserOptions which have been taken into account to produce this output.
Definition: ParserOutput.php:1142
ParserOutput\mergeMixedList
static mergeMixedList(array $a, array $b)
Definition: ParserOutput.php:1568
ParserOutput\addExtraCSPScriptSrc
addExtraCSPScriptSrc( $src)
Add an extra value to Content-Security-Policy script-src directive.
Definition: ParserOutput.php:1381
ParserOutput\setLimitReportData
setLimitReportData( $key, $value)
Sets parser limit report data for a key.
Definition: ParserOutput.php:1288
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:1541
ParserOutput\merge2D
static merge2D(array $a, array $b)
Definition: ParserOutput.php:1580
ParserOutput\addWrapperDivClass
addWrapperDivClass( $class)
Add a CSS class to use for the wrapping div.
Definition: ParserOutput.php:443
ParserOutput\$mLimitReportJSData
array $mLimitReportJSData
Parser limit report data for JSON.
Definition: ParserOutput.php:197
ParserOutput\$mModules
array $mModules
Modules to be loaded by ResourceLoader.
Definition: ParserOutput.php:128
ParserOutput\__sleep
__sleep()
Definition: ParserOutput.php:1410
ParserOutput\setNewSection
setNewSection( $value)
Definition: ParserOutput.php:755
ParserOutput\getModules
getModules()
Definition: ParserOutput.php:609
ParserOutput\$mAccessedOptions
true[] $mAccessedOptions
List of ParserOptions (stored in the keys).
Definition: ParserOutput.php:184
ParserOutput\getImages
& getImages()
Definition: ParserOutput.php:585
ParserOutput\addModules
addModules( $modules)
Definition: ParserOutput.php:906
ParserOutput\MIN_AR_TTL
const MIN_AR_TTL
Definition: ParserOutput.php:264
ParserOutput\$mOutputHooks
array $mOutputHooks
Hook tags as per $wgParserOutputHooks.
Definition: ParserOutput.php:143
ParserOutput\setIndicator
setIndicator( $id, $content)
Definition: ParserOutput.php:728
ParserOutput\addTemplate
addTemplate( $title, $page_id, $rev_id)
Register a template dependency for this output.
Definition: ParserOutput.php:859
ParserOutput\getJsConfigVars
getJsConfigVars()
Definition: ParserOutput.php:621
wfUrlencode
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
Definition: GlobalFunctions.php:309
ParserOutput\mergeTrackingMetaDataFrom
mergeTrackingMetaDataFrom(ParserOutput $source)
Merges dependency tracking metadata such as backlinks, images used, and extension data from $source i...
Definition: ParserOutput.php:1538
ParserOutput\addExtraCSPStyleSrc
addExtraCSPStyleSrc( $src)
Add an extra value to Content-Security-Policy style-src directive.
Definition: ParserOutput.php:1369
OutputPage\getModuleStyles
getModuleStyles( $filter=false, $position=null)
Get the list of style-only modules to load on this page.
Definition: OutputPage.php:566
NS_FILE
const NS_FILE
Definition: Defines.php:75
ParserOutput\unsetProperty
unsetProperty( $name)
Definition: ParserOutput.php:1126
ParserOutput\setFlag
setFlag( $flag)
Attach a flag to the output so that it can be checked later to handle special cases.
Definition: ParserOutput.php:1030
ParserOutput\hideNewSection
hideNewSection( $value)
Definition: ParserOutput.php:759
ParserOutput\addLink
addLink(Title $title, $id=null)
Record a local or interwiki inline link for saving in future link tables.
Definition: ParserOutput.php:812
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1198
ParserOutput\$mMaxAdaptiveExpiry
int $mMaxAdaptiveExpiry
Upper bound of expiry based on parse duration.
Definition: ParserOutput.php:252
$s
$s
Definition: mergeMessageFileList.php:185
ParserOutput\__construct
__construct( $text='', $languageLinks=[], $categoryLinks=[], $unused=false, $titletext='')
Definition: ParserOutput.php:275
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1064
ParserOutput\EDITSECTION_REGEX
const EDITSECTION_REGEX
Definition: ParserOutput.php:254
ParserOutput\PARSE_SLOW_SEC
const PARSE_SLOW_SEC
Definition: ParserOutput.php:261
ParserOutput\getHeadItems
getHeadItems()
Definition: ParserOutput.php:605
ParserOutput\PARSE_FAST_SEC
const PARSE_FAST_SEC
Definition: ParserOutput.php:260
ParserOutput\setSpeculativePageIdUsed
setSpeculativePageIdUsed( $id)
Definition: ParserOutput.php:486
ParserOutput\getProperties
getProperties()
Definition: ParserOutput.php:1130
ParserOutput\mergeList
static mergeList(array $a, array $b)
Definition: ParserOutput.php:1572
ParserOutput\$mProperties
array $mProperties
Name/value pairs to be cached in the DB.
Definition: ParserOutput.php:159
ParserOutput\getModuleStyles
getModuleStyles()
Definition: ParserOutput.php:613
ParserOutput\$mHeadItems
array $mHeadItems
Items to put in the <head> section.
Definition: ParserOutput.php:123
ParserOutput\$mTimestamp
string $mTimestamp
Timestamp of the revision.
Definition: ParserOutput.php:169
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:58
ParserOutput\getExtraCSPDefaultSrcs
getExtraCSPDefaultSrcs()
Get extra Content-Security-Policy 'default-src' directives.
Definition: ParserOutput.php:665
ParserOutput\addExtraCSPDefaultSrc
addExtraCSPDefaultSrc( $src)
Add an extra value to Content-Security-Policy default-src directive.
Definition: ParserOutput.php:1359
ParserOutput\getLimitReportJSData
getLimitReportJSData()
Definition: ParserOutput.php:652
MWException
MediaWiki exception.
Definition: MWException.php:26
Parser\TOC_START
const TOC_START
Definition: Parser.php:143
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:541
ParserOutput\getCategoryLinks
getCategoryLinks()
Definition: ParserOutput.php:549
ParserOutput\setRevisionUsedSha1Base36
setRevisionUsedSha1Base36( $hash)
Definition: ParserOutput.php:518
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:1038
ParserOutput\getTimestamp
getTimestamp()
Definition: ParserOutput.php:644
ParserOutput\isLinkInternal
static isLinkInternal( $internal, $url)
Checks, if a url is pointing to the own server.
Definition: ParserOutput.php:778
ParserOutput\addExternalLink
addExternalLink( $url)
Definition: ParserOutput.php:789
ParserOutput\$mExtraDefaultSrcs
array $mExtraDefaultSrcs
Extra default-src for CSP [Everything but script and style].
Definition: ParserOutput.php:217
ParserOutput\getInterwikiLinks
getInterwikiLinks()
Definition: ParserOutput.php:545
ParserOutput\$mLimitReportData
array $mLimitReportData
Parser limit report data.
Definition: ParserOutput.php:194
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:1469
ParserOutput\updateRuntimeAdaptiveExpiry
updateRuntimeAdaptiveExpiry( $ttl)
Lower the runtime adaptive TTL to at most this value.
Definition: ParserOutput.php:1345
ParserOutput\getTimeSinceStart
getTimeSinceStart( $clock)
Returns the time since resetParseStartTime() was last called.
Definition: ParserOutput.php:1260
$modules
$modules
Definition: HTMLFormElement.php:13
ParserOutput\addImage
addImage( $name, $timestamp=null, $sha1=null)
Register a file dependency for this output.
Definition: ParserOutput.php:846
ParserOutput\$mHideNewSection
bool $mHideNewSection
Hide the new section link?
Definition: ParserOutput.php:113
ParserOutput\$mTemplates
array $mTemplates
2-D map of NS/DBK to ID for the template references.
Definition: ParserOutput.php:76
ParserOutput\$mNewSection
bool $mNewSection
Show a new section link?
Definition: ParserOutput.php:108
$wgParserCacheExpireTime
$wgParserCacheExpireTime
The expiry time for the parser cache, in seconds.
Definition: DefaultSettings.php:2624
ParserOutput\getTimes
static getTimes( $clock=null)
Definition: ParserOutput.php:1228
ParserOutput\addCategory
addCategory( $c, $sort)
Definition: ParserOutput.php:719
ParserOutput\useMaxValue
static useMaxValue( $a, $b)
Definition: ParserOutput.php:1626
Parser\TOC_END
const TOC_END
Definition: Parser.php:144
$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:914
ParserOutput\mergeInternalMetaDataFrom
mergeInternalMetaDataFrom(ParserOutput $source)
Merges internal metadata such as flags, accessed options, and profiling info from $source into this P...
Definition: ParserOutput.php:1433
ParserOutput\setText
setText( $text)
Definition: ParserOutput.php:687
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:133
ParserOutput\getDisplayTitle
getDisplayTitle()
Get the title to be used for display.
Definition: ParserOutput.php:1017
ParserOutput\$mFlags
array $mFlags
Generic flags.
Definition: ParserOutput.php:227
ParserOutput\getIndicators
getIndicators()
Definition: ParserOutput.php:561
ParserOutput\setLanguageLinks
setLanguageLinks( $ll)
Definition: ParserOutput.php:691
ParserOutput\getSpeculativePageIdUsed
getSpeculativePageIdUsed()
Definition: ParserOutput.php:494
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:913
OutputPage
This is one of the Core classes and should be read at least once by any new developers.
Definition: OutputPage.php:46
ParserOutput\getLanguageLinks
& getLanguageLinks()
Definition: ParserOutput.php:541
ParserOutput\$mPreventClickjacking
bool $mPreventClickjacking
Whether to emit X-Frame-Options: DENY.
Definition: ParserOutput.php:207
ParserOutput\getExternalLinks
& getExternalLinks()
Definition: ParserOutput.php:593
ParserOutput\getTemplateIds
& getTemplateIds()
Definition: ParserOutput.php:581
OutputPage\getPreventClickjacking
getPreventClickjacking()
Get the prevent-clickjacking flag.
Definition: OutputPage.php:2363
ParserOutput\getTOCHTML
getTOCHTML()
Definition: ParserOutput.php:637
ParserOutput\recordOption
recordOption( $option)
Tags a parser option for use in the cache key for this parser output.
Definition: ParserOutput.php:1161
ParserOutput\addOutputHook
addOutputHook( $hook, $data=false)
Definition: ParserOutput.php:751
ParserOutput\getExtraCSPScriptSrcs
getExtraCSPScriptSrcs()
Get extra Content-Security-Policy 'script-src' directives.
Definition: ParserOutput.php:674
ParserOutput\SLOW_AR_TTL
const SLOW_AR_TTL
Definition: ParserOutput.php:263
ParserOutput\getTitleText
getTitleText()
Definition: ParserOutput.php:565
ParserOutput\clearWrapperDivClass
clearWrapperDivClass()
Clears the CSS class to use for the wrapping div, effectively disabling the wrapper div until addWrap...
Definition: ParserOutput.php:451
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:621
ParserOutput\setProperty
setProperty( $name, $value)
Set a property to be stored in the page_props database table.
Definition: ParserOutput.php:1110
ParserOutput\getNewSection
getNewSection()
Definition: ParserOutput.php:767
Hooks\runWithoutAbort
static runWithoutAbort( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:150
$content
$content
Definition: router.php:76
ParserOutput\setExtensionData
setExtensionData( $key, $value)
Attaches arbitrary data to this ParserObject.
Definition: ParserOutput.php:1205
ParserOutput\$mExtensionData
array $mExtensionData
extra data used by extensions.
Definition: ParserOutput.php:189
OutputPage\getHeadItemsArray
getHeadItemsArray()
Get an array of head items.
Definition: OutputPage.php:649
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:57
ParserOutput\getOutputHooks
getOutputHooks()
Definition: ParserOutput.php:625
ParserOutput\$speculativePageIdUsed
int null $speculativePageIdUsed
Assumed page ID for {{PAGEID}} if no revision is set.
Definition: ParserOutput.php:239
ParserOutput\getHideNewSection
getHideNewSection()
Definition: ParserOutput.php:763
$wgServer
$wgServer
URL of the server.
Definition: DefaultSettings.php:105
ParserOutput\$revisionUsedSha1Base36
string null $revisionUsedSha1Base36
SHA-1 base 36 hash of any self-transclusion.
Definition: ParserOutput.php:244
ParserOutput\$mExtraStyleSrcs
array $mExtraStyleSrcs
Extra style-src for CSP.
Definition: ParserOutput.php:222
ParserOutput\getRevisionUsedSha1Base36
getRevisionUsedSha1Base36()
Definition: ParserOutput.php:537
ParserOutput\$mExtraScriptSrcs
array $mExtraScriptSrcs
Extra script-src for CSP.
Definition: ParserOutput.php:212
ParserOutput\getNoGallery
getNoGallery()
Definition: ParserOutput.php:601
ParserOutput\addWarning
addWarning( $s)
Definition: ParserOutput.php:747
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:451
ParserOutput\$mTemplateIds
array $mTemplateIds
2-D map of NS/DBK to rev ID for the template references.
Definition: ParserOutput.php:82
ParserOutput\getTemplates
& getTemplates()
Definition: ParserOutput.php:577
ParserOutput\setSections
setSections( $toc)
Definition: ParserOutput.php:703
ParserOutput\setCategoryLinks
setCategoryLinks( $cl)
Definition: ParserOutput.php:695
ParserOutput\$mParseStartTime
array $mParseStartTime
Timestamps for getTimeSinceStart().
Definition: ParserOutput.php:202
ParserOutput\getRevisionTimestampUsed
getRevisionTimestampUsed()
Definition: ParserOutput.php:510
ParserOutput\getFileSearchOptions
& getFileSearchOptions()
Definition: ParserOutput.php:589
Title
Represents a title within MediaWiki.
Definition: Title.php:42
ParserOutput\$mTOCHTML
string $mTOCHTML
HTML of the TOC.
Definition: ParserOutput.php:164
ParserOutput\getProperty
getProperty( $name)
Definition: ParserOutput.php:1122
Parser\normalizeLinkUrl
static normalizeLinkUrl( $url)
Replace unusual escape codes in a URL with their equivalent characters.
Definition: Parser.php:2215
ParserOutput\$mExternalLinks
array $mExternalLinks
External link URLs, in the key only.
Definition: ParserOutput.php:97
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:262
ParserOutput\addJsConfigVars
addJsConfigVars( $keys, $value=null)
Add one or more variables to be set in mw.config in JavaScript.
Definition: ParserOutput.php:925
ParserOutput\getCategories
& getCategories()
Definition: ParserOutput.php:553
ParserOutput\hasText
hasText()
Returns true if text was passed to the constructor, or set using setText().
Definition: ParserOutput.php:294
ParserOutput\$mNoGallery
bool $mNoGallery
No gallery on category page? (NOGALLERY).
Definition: ParserOutput.php:118
ParserOutput\getRawText
getRawText()
Get the cacheable text with <mw:editsection> markers still in it.
Definition: ParserOutput.php:306
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:1614
ParserOutput\$mIndexPolicy
string $mIndexPolicy
'index' or 'noindex'? Any other value will result in no change.
Definition: ParserOutput.php:179
$keys
$keys
Definition: testCompression.php:72
ParserOutput\getLimitReportData
getLimitReportData()
Definition: ParserOutput.php:648
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:966
$source
$source
Definition: mwdoc-filter.php:34
ParserOutput\useEachMinValue
static useEachMinValue(array $a, array $b)
Definition: ParserOutput.php:1599
ParserOutput\getExtensionData
getExtensionData( $key)
Gets extensions data previously attached to this ParserOutput using setExtensionData().
Definition: ParserOutput.php:1224
ParserOutput\addLanguageLink
addLanguageLink( $t)
Definition: ParserOutput.php:743
ParserOutput\$mInterwikiLinks
array $mInterwikiLinks
2-D map of prefix/DBK (in keys only) for the inline interwiki links in the document.
Definition: ParserOutput.php:103
Sanitizer\decodeTagAttributes
static decodeTagAttributes( $text)
Return an associative array of attribute names and values from a partial tag string.
Definition: Sanitizer.php:1292
ParserOutput\getText
getText( $options=[])
Get the output HTML.
Definition: ParserOutput.php:340
ParserOutput\setRevisionTimestampUsed
setRevisionTimestampUsed( $timestamp)
Definition: ParserOutput.php:502
$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:1511
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:241
ParserOutput\$mSections
array $mSections
Table of contents.
Definition: ParserOutput.php:154
ParserOutput\$mText
string null $mText
The output text.
Definition: ParserOutput.php:42
ParserOutput\addInterwikiLink
addInterwikiLink( $title)
Definition: ParserOutput.php:876
ParserOutput\setTOCHTML
setTOCHTML( $tochtml)
Definition: ParserOutput.php:711
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:3221
$wgRegisterInternalExternals
$wgRegisterInternalExternals
By default MediaWiki does not register links pointing to same server in externallinks dataset,...
Definition: DefaultSettings.php:8938
ParserOutput\getSections
getSections()
Definition: ParserOutput.php:569
ParserOutput\$mSpeculativeRevId
int null $mSpeculativeRevId
Assumed rev ID for {{REVISIONID}} if no revision is set.
Definition: ParserOutput.php:229
ParserOutput\hasDynamicContent
hasDynamicContent()
Check whether the cache TTL was lowered due to dynamic content.
Definition: ParserOutput.php:1322
ParserOutput\addHeadItem
addHeadItem( $section, $tag=false)
Add some text to the "<head>".
Definition: ParserOutput.php:894
ParserOutput\setEnableOOUI
setEnableOOUI( $enable=false)
Enables OOUI, if true, in any OutputPage instance this ParserOutput object is added to.
Definition: ParserOutput.php:739
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:1390
ParserOutput\getSpeculativeRevIdUsed
getSpeculativeRevIdUsed()
Definition: ParserOutput.php:478
ParserOutput\getLinks
& getLinks()
Definition: ParserOutput.php:573
ParserOutput\setIndexPolicy
setIndexPolicy( $policy)
Definition: ParserOutput.php:707
ParserOutput\setNoGallery
setNoGallery( $value)
Definition: ParserOutput.php:597
ParserOutput\getAllFlags
getAllFlags()
Definition: ParserOutput.php:1046
ParserOutput\getIndexPolicy
getIndexPolicy()
Definition: ParserOutput.php:633
ParserOutput\getExtraCSPStyleSrcs
getExtraCSPStyleSrcs()
Get extra Content-Security-Policy 'style-src' directives.
Definition: ParserOutput.php:683
ParserOutput\getWrapperDivClass
getWrapperDivClass()
Returns the class (or classes) to be used with the wrapper div for this otuput.
Definition: ParserOutput.php:462
ParserOutput\preventClickjacking
preventClickjacking( $flag=null)
Get or set the prevent-clickjacking flag.
Definition: ParserOutput.php:1335
ParserOutput\getWarnings
getWarnings()
Definition: ParserOutput.php:629