MediaWiki  master
ParserOptions.php
Go to the documentation of this file.
1 <?php
27 use Wikimedia\ScopedCallback;
28 
45 
51  private static $defaults = null;
52 
57  private static $lazyOptions = null;
58 
63  private static $initialLazyOptions = [
64  'dateformat' => [ __CLASS__, 'initDateFormat' ],
65  'speculativeRevId' => [ __CLASS__, 'initSpeculativeRevId' ],
66  'speculativePageId' => [ __CLASS__, 'initSpeculativePageId' ],
67  ];
68 
73  private static $cacheVaryingOptionsHash = null;
74 
80  'dateformat' => true,
81  'numberheadings' => true,
82  'thumbsize' => true,
83  'printable' => true,
84  'userlang' => true,
85  ];
86 
92  private static $callbacks = [
93  'currentRevisionCallback' => true,
94  'currentRevisionRecordCallback' => true,
95  'templateCallback' => true,
96  'speculativeRevIdCallback' => true,
97  'speculativePageIdCallback' => true,
98  ];
99 
104  private $options;
105 
111  private $mTimestamp;
112 
118  private $mUser;
119 
125  private $onAccessCallback = null;
126 
133  private $redirectTarget = null;
134 
138  private $mExtraKey = '';
139 
146  public function getOption( $name ) {
147  if ( !array_key_exists( $name, $this->options ) ) {
148  throw new InvalidArgumentException( "Unknown parser option $name" );
149  }
150 
151  $this->lazyLoadOption( $name );
152  $this->optionUsed( $name );
153  return $this->options[$name];
154  }
155 
159  private function lazyLoadOption( $name ) {
161  if ( isset( $lazyOptions[$name] ) && $this->options[$name] === null ) {
162  $this->options[$name] = call_user_func( $lazyOptions[$name], $this, $name );
163  }
164  }
165 
177  public static function getLazyOptions(): array {
178  return self::$lazyOptions;
179  }
180 
189  private static function getCacheVaryingOptionsHash(): array {
190  // Trigger a call to the 'ParserOptionsRegister' hook if it hasn't
191  // already been called.
192  if ( self::$cacheVaryingOptionsHash === null ) {
194  }
196  }
197 
206  public function setOption( $name, $value ) {
207  if ( !array_key_exists( $name, $this->options ) ) {
208  throw new InvalidArgumentException( "Unknown parser option $name" );
209  }
210  $old = $this->options[$name];
211  $this->options[$name] = $value;
212  return $old;
213  }
214 
223  protected function setOptionLegacy( $name, $value ) {
224  if ( !array_key_exists( $name, $this->options ) ) {
225  throw new InvalidArgumentException( "Unknown parser option $name" );
226  }
227  return wfSetVar( $this->options[$name], $value );
228  }
229 
238  public function getInterwikiMagic() {
239  return $this->getOption( 'interwikiMagic' );
240  }
241 
247  public function setInterwikiMagic( $x ) {
248  return $this->setOptionLegacy( 'interwikiMagic', $x );
249  }
250 
255  public function getAllowExternalImages() {
256  return $this->getOption( 'allowExternalImages' );
257  }
258 
266  public function setAllowExternalImages( $x ) {
267  wfDeprecated( __METHOD__, '1.35' );
268  return $this->setOptionLegacy( 'allowExternalImages', $x );
269  }
270 
278  public function getAllowExternalImagesFrom() {
279  return $this->getOption( 'allowExternalImagesFrom' );
280  }
281 
292  public function setAllowExternalImagesFrom( $x ) {
293  wfDeprecated( __METHOD__, '1.35' );
294  return $this->setOptionLegacy( 'allowExternalImagesFrom', $x );
295  }
296 
301  public function getEnableImageWhitelist() {
302  return $this->getOption( 'enableImageWhitelist' );
303  }
304 
312  public function setEnableImageWhitelist( $x ) {
313  wfDeprecated( __METHOD__, '1.35' );
314  return $this->setOptionLegacy( 'enableImageWhitelist', $x );
315  }
316 
321  public function getNumberHeadings() {
322  return $this->getOption( 'numberheadings' );
323  }
324 
330  public function setNumberHeadings( $x ) {
331  return $this->setOptionLegacy( 'numberheadings', $x );
332  }
333 
338  public function getAllowSpecialInclusion() {
339  return $this->getOption( 'allowSpecialInclusion' );
340  }
341 
347  public function setAllowSpecialInclusion( $x ) {
348  return $this->setOptionLegacy( 'allowSpecialInclusion', $x );
349  }
350 
357  public function setTidy( $x ) {
358  wfDeprecated( __METHOD__, '1.35' );
359  // This has no effect.
360  return null;
361  }
362 
367  public function getInterfaceMessage() {
368  return $this->getOption( 'interfaceMessage' );
369  }
370 
376  public function setInterfaceMessage( $x ) {
377  return $this->setOptionLegacy( 'interfaceMessage', $x );
378  }
379 
384  public function getTargetLanguage() {
385  return $this->getOption( 'targetLanguage' );
386  }
387 
393  public function setTargetLanguage( $x ) {
394  return $this->setOption( 'targetLanguage', $x );
395  }
396 
401  public function getMaxIncludeSize() {
402  return $this->getOption( 'maxIncludeSize' );
403  }
404 
410  public function setMaxIncludeSize( $x ) {
411  return $this->setOptionLegacy( 'maxIncludeSize', $x );
412  }
413 
418  public function getMaxPPNodeCount() {
419  return $this->getOption( 'maxPPNodeCount' );
420  }
421 
427  public function setMaxPPNodeCount( $x ) {
428  return $this->setOptionLegacy( 'maxPPNodeCount', $x );
429  }
430 
435  public function getMaxPPExpandDepth() {
436  return $this->getOption( 'maxPPExpandDepth' );
437  }
438 
443  public function getMaxTemplateDepth() {
444  return $this->getOption( 'maxTemplateDepth' );
445  }
446 
452  public function setMaxTemplateDepth( $x ) {
453  return $this->setOptionLegacy( 'maxTemplateDepth', $x );
454  }
455 
462  return $this->getOption( 'expensiveParserFunctionLimit' );
463  }
464 
471  public function setExpensiveParserFunctionLimit( $x ) {
472  return $this->setOptionLegacy( 'expensiveParserFunctionLimit', $x );
473  }
474 
480  public function getRemoveComments() {
481  return $this->getOption( 'removeComments' );
482  }
483 
490  public function setRemoveComments( $x ) {
491  return $this->setOptionLegacy( 'removeComments', $x );
492  }
493 
498  public function getEnableLimitReport() {
499  return $this->getOption( 'enableLimitReport' );
500  }
501 
507  public function enableLimitReport( $x = true ) {
508  return $this->setOptionLegacy( 'enableLimitReport', $x );
509  }
510 
516  public function getCleanSignatures() {
517  return $this->getOption( 'cleanSignatures' );
518  }
519 
526  public function setCleanSignatures( $x ) {
527  return $this->setOptionLegacy( 'cleanSignatures', $x );
528  }
529 
534  public function getExternalLinkTarget() {
535  return $this->getOption( 'externalLinkTarget' );
536  }
537 
543  public function setExternalLinkTarget( $x ) {
544  return $this->setOptionLegacy( 'externalLinkTarget', $x );
545  }
546 
551  public function getDisableContentConversion() {
552  return $this->getOption( 'disableContentConversion' );
553  }
554 
560  public function disableContentConversion( $x = true ) {
561  return $this->setOptionLegacy( 'disableContentConversion', $x );
562  }
563 
568  public function getDisableTitleConversion() {
569  return $this->getOption( 'disableTitleConversion' );
570  }
571 
577  public function disableTitleConversion( $x = true ) {
578  return $this->setOptionLegacy( 'disableTitleConversion', $x );
579  }
580 
585  public function getThumbSize() {
586  return $this->getOption( 'thumbsize' );
587  }
588 
594  public function setThumbSize( $x ) {
595  return $this->setOptionLegacy( 'thumbsize', $x );
596  }
597 
602  public function getStubThreshold() {
603  return $this->getOption( 'stubthreshold' );
604  }
605 
611  public function setStubThreshold( $x ) {
612  return $this->setOptionLegacy( 'stubthreshold', $x );
613  }
614 
619  public function getIsPreview() {
620  return $this->getOption( 'isPreview' );
621  }
622 
628  public function setIsPreview( $x ) {
629  return $this->setOptionLegacy( 'isPreview', $x );
630  }
631 
636  public function getIsSectionPreview() {
637  return $this->getOption( 'isSectionPreview' );
638  }
639 
645  public function setIsSectionPreview( $x ) {
646  return $this->setOptionLegacy( 'isSectionPreview', $x );
647  }
648 
653  public function getIsPrintable() {
654  return $this->getOption( 'printable' );
655  }
656 
662  public function setIsPrintable( $x ) {
663  return $this->setOptionLegacy( 'printable', $x );
664  }
665 
670  public function getPreSaveTransform() {
671  return $this->getOption( 'preSaveTransform' );
672  }
673 
679  public function setPreSaveTransform( $x ) {
680  return $this->setOptionLegacy( 'preSaveTransform', $x );
681  }
682 
687  public function getDateFormat() {
688  return $this->getOption( 'dateformat' );
689  }
690 
696  private static function initDateFormat( ParserOptions $popt ) {
697  return $popt->mUser->getDatePreference();
698  }
699 
705  public function setDateFormat( $x ) {
706  return $this->setOptionLegacy( 'dateformat', $x );
707  }
708 
726  public function getUserLangObj() {
727  return $this->getOption( 'userlang' );
728  }
729 
742  public function getUserLang() {
743  return $this->getUserLangObj()->getCode();
744  }
745 
751  public function setUserLang( $x ) {
752  if ( is_string( $x ) ) {
753  $x = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( $x );
754  }
755 
756  return $this->setOptionLegacy( 'userlang', $x );
757  }
758 
764  public function getMagicISBNLinks() {
765  return $this->getOption( 'magicISBNLinks' );
766  }
767 
773  public function getMagicPMIDLinks() {
774  return $this->getOption( 'magicPMIDLinks' );
775  }
776 
782  public function getMagicRFCLinks() {
783  return $this->getOption( 'magicRFCLinks' );
784  }
785 
800  public function getAllowUnsafeRawHtml() {
801  return $this->getOption( 'allowUnsafeRawHtml' );
802  }
803 
812  public function setAllowUnsafeRawHtml( $x ) {
813  return $this->setOptionLegacy( 'allowUnsafeRawHtml', $x );
814  }
815 
821  public function getWrapOutputClass() {
822  return $this->getOption( 'wrapclass' );
823  }
824 
832  public function setWrapOutputClass( $className ) {
833  if ( $className === true ) { // DWIM, they probably want the default class name
834  $className = 'mw-parser-output';
835  }
836  if ( $className === false ) {
837  wfDeprecated( __METHOD__ . '( false )', '1.31' );
838  }
839  return $this->setOption( 'wrapclass', $className );
840  }
841 
848  public function getCurrentRevisionCallback() {
849  wfDeprecated( __METHOD__, '1.35' );
850  $revCb = $this->getOption( 'currentRevisionCallback' );
851 
852  // As a temporary measure, while both currentRevisionCallback and
853  // currentRevisionRecordCallback are supported, retrieving one that is
854  // not set first checks if the other is set, so that the end result works
855  // regardless of which setter was used, since one extension may set a
856  // RevisionCallback and another may ask for the RevisionRecordCallback
857  if ( $revCb === [ Parser::class, 'statelessFetchRevision' ] ) {
858  // currentRevisionCallback is set to the default, check if
859  // currentRevisionRecordCallback is set (and not the default)
860  $revRecordCb = $this->getOption( 'currentRevisionRecordCallback' );
861  if ( $revRecordCb !== [ Parser::class, 'statelessFetchRevisionRecord' ] ) {
862  // currentRevisionRecordCallback is set and not the default,
863  // convert it
864  $revCb = static function ( Title $title, $parser = false ) use ( $revRecordCb ) {
865  $revRecord = call_user_func(
866  $revRecordCb,
867  $title,
868  $parser ?: null
869  );
870  if ( $revRecord ) {
871  return new Revision( $revRecord );
872  }
873  return false;
874  };
875  }
876  }
877  return $revCb;
878  }
879 
887  $revRecordCb = $this->getOption( 'currentRevisionRecordCallback' );
888 
889  // See explanation above
890  if ( $revRecordCb === [ Parser::class, 'statelessFetchRevisionRecord' ] ) {
891  // currentRevisionRecordCallback is set to the default, check if
892  // currentRevisionCallback is set (and not the default)
893  $revCb = $this->getOption( 'currentRevisionCallback' );
894  if ( $revCb !== [ Parser::class, 'statelessFetchRevision' ] ) {
895  // currentRevisionCallback is set and not the default, convert it
896  $revRecordCb = static function ( Title $title, $parser = null ) use ( $revCb ) {
897  $rev = call_user_func( $revCb, $title, $parser ?? false );
898  if ( $rev ) {
899  return $rev->getRevisionRecord();
900  }
901  return false;
902  };
903  }
904  }
905  return $revRecordCb;
906  }
907 
915  public function setCurrentRevisionCallback( $x ) {
916  wfDeprecated( __METHOD__, '1.35' );
917  return $this->setOptionLegacy( 'currentRevisionCallback', $x );
918  }
919 
927  public function setCurrentRevisionRecordCallback( $x ) {
928  return $this->setOption( 'currentRevisionRecordCallback', $x );
929  }
930 
935  public function getTemplateCallback() {
936  return $this->getOption( 'templateCallback' );
937  }
938 
944  public function setTemplateCallback( $x ) {
945  return $this->setOptionLegacy( 'templateCallback', $x );
946  }
947 
958  public function getSpeculativeRevId() {
959  return $this->getOption( 'speculativeRevId' );
960  }
961 
972  public function getSpeculativePageId() {
973  return $this->getOption( 'speculativePageId' );
974  }
975 
982  private static function initSpeculativeRevId( ParserOptions $popt ) {
983  $cb = $popt->getOption( 'speculativeRevIdCallback' );
984  $id = $cb ? $cb() : null;
985 
986  // returning null would result in this being re-called every access
987  return $id ?? false;
988  }
989 
996  private static function initSpeculativePageId( ParserOptions $popt ) {
997  $cb = $popt->getOption( 'speculativePageIdCallback' );
998  $id = $cb ? $cb() : null;
999 
1000  // returning null would result in this being re-called every access
1001  return $id ?? false;
1002  }
1003 
1010  public function setSpeculativeRevIdCallback( $x ) {
1011  $this->setOption( 'speculativeRevId', null ); // reset
1012  return $this->setOption( 'speculativeRevIdCallback', $x );
1013  }
1014 
1021  public function setSpeculativePageIdCallback( $x ) {
1022  $this->setOption( 'speculativePageId', null ); // reset
1023  return $this->setOption( 'speculativePageIdCallback', $x );
1024  }
1025 
1030  public function getTimestamp() {
1031  if ( !isset( $this->mTimestamp ) ) {
1032  $this->mTimestamp = wfTimestampNow();
1033  }
1034  return $this->mTimestamp;
1035  }
1036 
1042  public function setTimestamp( $x ) {
1043  return wfSetVar( $this->mTimestamp, $x );
1044  }
1045 
1054  public function setRedirectTarget( $title ) {
1055  $this->redirectTarget = $title;
1056  }
1057 
1064  public function getRedirectTarget() {
1065  return $this->redirectTarget;
1066  }
1067 
1074  public function addExtraKey( $key ) {
1075  $this->mExtraKey .= '!' . $key;
1076  }
1077 
1082  public function getUser() {
1083  return $this->mUser;
1084  }
1085 
1092  public function __construct( $user = null, $lang = null ) {
1093  if ( $user === null ) {
1094  wfDeprecated( __CLASS__ . ' being created with a User object', '1.36' );
1095  global $wgUser;
1096  if ( $wgUser === null ) {
1097  $user = new User;
1098  } else {
1099  $user = $wgUser;
1100  }
1101  }
1102  if ( $lang === null ) {
1103  global $wgLang;
1105  $lang = $wgLang;
1106  }
1107  $this->initialiseFromUser( $user, $lang );
1108  }
1109 
1117  public static function newFromAnon() {
1118  return new ParserOptions( new User,
1119  MediaWikiServices::getInstance()->getContentLanguage() );
1120  }
1121 
1131  public static function newFromUser( $user ) {
1132  return new ParserOptions( $user );
1133  }
1134 
1144  public static function newFromUserAndLang( User $user, Language $lang ) {
1145  return new ParserOptions( $user, $lang );
1146  }
1147 
1156  public static function newFromContext( IContextSource $context ) {
1157  return new ParserOptions( $context->getUser(), $context->getLanguage() );
1158  }
1159 
1178  public static function newCanonical( $context = null, $userLang = null ) {
1179  if ( $context instanceof IContextSource ) {
1180  $ret = self::newFromContext( $context );
1181  } elseif ( $context === 'canonical' ) {
1182  $ret = self::newFromAnon();
1183  } elseif ( $context instanceof User || $context === null ) {
1184  if ( $context === null ) {
1185  wfDeprecated( __METHOD__ . ' with no user', '1.35' );
1186 
1187  // Avoid sending out another deprecation notice from calling
1188  // __construct with null
1189  // TODO remove support for this instead
1190  global $wgUser;
1191  $context = $wgUser;
1192  }
1193  $ret = new self( $context, $userLang );
1194  } else {
1195  throw new InvalidArgumentException(
1196  '$context must be an IContextSource, the string "canonical", a User, or null'
1197  );
1198  }
1199 
1200  foreach ( self::getCanonicalOverrides() as $k => $v ) {
1201  $ret->setOption( $k, $v );
1202  }
1203  return $ret;
1204  }
1205 
1210  public static function clearStaticCache() {
1211  if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
1212  throw new RuntimeException( __METHOD__ . ' is just for testing' );
1213  }
1214  self::$defaults = null;
1215  self::$lazyOptions = null;
1216  self::$cacheVaryingOptionsHash = null;
1217  }
1218 
1228  private static function getDefaults() {
1234  $services = MediaWikiServices::getInstance();
1235  $languageConverterFactory = $services->getLanguageConverterFactory();
1236  $userOptionsLookup = $services->getUserOptionsLookup();
1237  $contentLanguage = $services->getContentLanguage();
1238 
1239  if ( self::$defaults === null ) {
1240  // *UPDATE* ParserOptions::matches() if any of this changes as needed
1241  self::$defaults = [
1242  'dateformat' => null,
1243  'interfaceMessage' => false,
1244  'targetLanguage' => null,
1245  'removeComments' => true,
1246  'enableLimitReport' => false,
1247  'preSaveTransform' => true,
1248  'isPreview' => false,
1249  'isSectionPreview' => false,
1250  'printable' => false,
1251  'allowUnsafeRawHtml' => true,
1252  'wrapclass' => 'mw-parser-output',
1253  'currentRevisionCallback' => [ Parser::class, 'statelessFetchRevision' ],
1254  'currentRevisionRecordCallback' => [ Parser::class, 'statelessFetchRevisionRecord' ],
1255  'templateCallback' => [ Parser::class, 'statelessFetchTemplate' ],
1256  'speculativeRevIdCallback' => null,
1257  'speculativeRevId' => null,
1258  'speculativePageIdCallback' => null,
1259  'speculativePageId' => null,
1260  ];
1261 
1262  self::$cacheVaryingOptionsHash = self::$initialCacheVaryingOptionsHash;
1263  self::$lazyOptions = self::$initialLazyOptions;
1264 
1265  Hooks::runner()->onParserOptionsRegister(
1266  self::$defaults,
1267  self::$cacheVaryingOptionsHash,
1268  self::$lazyOptions
1269  );
1270 
1271  ksort( self::$cacheVaryingOptionsHash );
1272  }
1273 
1274  // Unit tests depend on being able to modify the globals at will
1275  return self::$defaults + [
1276  'interwikiMagic' => $wgInterwikiMagic,
1277  'allowExternalImages' => $wgAllowExternalImages,
1278  'allowExternalImagesFrom' => $wgAllowExternalImagesFrom,
1279  'enableImageWhitelist' => $wgEnableImageWhitelist,
1280  'allowSpecialInclusion' => $wgAllowSpecialInclusion,
1281  'maxIncludeSize' => $wgMaxArticleSize * 1024,
1282  'maxPPNodeCount' => $wgMaxPPNodeCount,
1283  'maxPPExpandDepth' => $wgMaxPPExpandDepth,
1284  'maxTemplateDepth' => $wgMaxTemplateDepth,
1285  'expensiveParserFunctionLimit' => $wgExpensiveParserFunctionLimit,
1286  'externalLinkTarget' => $wgExternalLinkTarget,
1287  'cleanSignatures' => $wgCleanSignatures,
1288  'disableContentConversion' => $languageConverterFactory->isConversionDisabled(),
1289  'disableTitleConversion' => $languageConverterFactory->isLinkConversionDisabled(),
1290  'magicISBNLinks' => $wgEnableMagicLinks['ISBN'],
1291  'magicPMIDLinks' => $wgEnableMagicLinks['PMID'],
1292  'magicRFCLinks' => $wgEnableMagicLinks['RFC'],
1293  'numberheadings' => $userOptionsLookup->getDefaultOption( 'numberheadings' ),
1294  'thumbsize' => $userOptionsLookup->getDefaultOption( 'thumbsize' ),
1295  'stubthreshold' => 0,
1296  'userlang' => $contentLanguage,
1297  ];
1298  }
1299 
1309  private static function getCanonicalOverrides() {
1311 
1312  return [
1313  'enableLimitReport' => $wgEnableParserLimitReporting,
1314  ];
1315  }
1316 
1323  private function initialiseFromUser( $user, $lang ) {
1324  $this->options = self::getDefaults();
1325 
1326  $this->mUser = $user;
1327  $this->options['numberheadings'] = $user->getOption( 'numberheadings' );
1328  $this->options['thumbsize'] = $user->getOption( 'thumbsize' );
1329  $this->options['stubthreshold'] = $user->getStubThreshold();
1330  $this->options['userlang'] = $lang;
1331  }
1332 
1342  public function matches( ParserOptions $other ) {
1343  // Compare most options
1344  $options = array_keys( $this->options );
1345  $options = array_diff( $options, [
1346  'enableLimitReport', // only affects HTML comments
1347  'tidy', // Has no effect since 1.35; removed in 1.36
1348  ] );
1349  foreach ( $options as $option ) {
1350  // Resolve any lazy options
1351  $this->lazyLoadOption( $option );
1352  $other->lazyLoadOption( $option );
1353 
1354  $o1 = $this->optionToString( $this->options[$option] );
1355  $o2 = $this->optionToString( $other->options[$option] );
1356  if ( $o1 !== $o2 ) {
1357  return false;
1358  }
1359  }
1360 
1361  // Compare most other fields
1362  foreach ( ( new ReflectionClass( $this ) )->getProperties() as $property ) {
1363  $field = $property->getName();
1364  if ( $property->isStatic() ) {
1365  continue;
1366  }
1367  if ( in_array( $field, [
1368  'options', // Already checked above
1369  'onAccessCallback', // only used for ParserOutput option tracking
1370  ] ) ) {
1371  continue;
1372  }
1373 
1374  if ( !is_object( $this->$field ) && $this->$field !== $other->$field ) {
1375  return false;
1376  }
1377  }
1378 
1379  return true;
1380  }
1381 
1387  public function matchesForCacheKey( ParserOptions $other ) {
1388  foreach ( self::allCacheVaryingOptions() as $option ) {
1389  // Populate any lazy options
1390  $this->lazyLoadOption( $option );
1391  $other->lazyLoadOption( $option );
1392 
1393  $o1 = $this->optionToString( $this->options[$option] );
1394  $o2 = $this->optionToString( $other->options[$option] );
1395  if ( $o1 !== $o2 ) {
1396  return false;
1397  }
1398  }
1399 
1400  return true;
1401  }
1402 
1408  public function registerWatcher( $callback ) {
1409  $this->onAccessCallback = $callback;
1410  }
1411 
1420  public function optionUsed( $optionName ) {
1421  if ( $this->onAccessCallback ) {
1422  call_user_func( $this->onAccessCallback, $optionName );
1423  }
1424  }
1425 
1431  public static function allCacheVaryingOptions() {
1432  return array_keys( array_filter( self::getCacheVaryingOptionsHash() ) );
1433  }
1434 
1440  private function optionToString( $value ) {
1441  if ( $value === true ) {
1442  return '1';
1443  } elseif ( $value === false ) {
1444  return '0';
1445  } elseif ( $value === null ) {
1446  return '';
1447  } elseif ( $value instanceof Language ) {
1448  return $value->getCode();
1449  } elseif ( is_array( $value ) ) {
1450  return '[' . implode( ',', array_map( [ $this, 'optionToString' ], $value ) ) . ']';
1451  } else {
1452  return (string)$value;
1453  }
1454  }
1455 
1468  public function optionsHash( $forOptions, $title = null ) {
1469  global $wgRenderHashAppend;
1470 
1471  $inCacheKey = self::allCacheVaryingOptions();
1472 
1473  // Resolve any lazy options
1474  $lazyOpts = array_intersect( $forOptions,
1475  $inCacheKey, array_keys( self::getLazyOptions() ) );
1476  foreach ( $lazyOpts as $k ) {
1477  $this->lazyLoadOption( $k );
1478  }
1479 
1482 
1483  // We only include used options with non-canonical values in the key
1484  // so adding a new option doesn't invalidate the entire parser cache.
1485  // The drawback to this is that changing the default value of an option
1486  // requires manual invalidation of existing cache entries, as mentioned
1487  // in the docs on the relevant methods and hooks.
1488  $values = [];
1489  foreach ( array_intersect( $inCacheKey, $forOptions ) as $option ) {
1490  $v = $this->optionToString( $options[$option] );
1491  $d = $this->optionToString( $defaults[$option] );
1492  if ( $v !== $d ) {
1493  $values[] = "$option=$v";
1494  }
1495  }
1496 
1497  $confstr = $values ? implode( '!', $values ) : 'canonical';
1498 
1499  // add in language specific options, if any
1500  // @todo FIXME: This is just a way of retrieving the url/user preferred variant
1501  $services = MediaWikiServices::getInstance();
1502  $lang = $title ? $title->getPageLanguage() : $services->getContentLanguage();
1503  $converter = $services->getLanguageConverterFactory()->getLanguageConverter( $lang );
1504  $confstr .= $converter->getExtraHashOptions();
1505 
1506  $confstr .= $wgRenderHashAppend;
1507 
1508  if ( $this->mExtraKey != '' ) {
1509  $confstr .= $this->mExtraKey;
1510  }
1511 
1512  // Give a chance for extensions to modify the hash, if they have
1513  // extra options or other effects on the parser cache.
1514  Hooks::runner()->onPageRenderingHash( $confstr, $this->getUser(), $forOptions );
1515 
1516  // Make it a valid memcached key fragment
1517  $confstr = str_replace( ' ', '_', $confstr );
1518 
1519  return $confstr;
1520  }
1521 
1528  public function isSafeToCache( array $usedOptions = null ) {
1530  $inCacheKey = self::getCacheVaryingOptionsHash();
1531  $usedOptions = $usedOptions ?? array_keys( $this->options );
1532  foreach ( $usedOptions as $option ) {
1533  if ( empty( $inCacheKey[$option] ) && empty( self::$callbacks[$option] ) ) {
1534  $v = $this->optionToString( $this->options[$option] ?? null );
1535  $d = $this->optionToString( $defaults[$option] ?? null );
1536  if ( $v !== $d ) {
1537  return false;
1538  }
1539  }
1540  }
1541  return true;
1542  }
1543 
1554  public function setupFakeRevision( $title, $content, $user ) {
1555  $oldCallback = $this->setCurrentRevisionRecordCallback(
1556  static function (
1557  $titleToCheck, $parser = null ) use ( $title, $content, $user, &$oldCallback
1558  ) {
1559  if ( $titleToCheck->equals( $title ) ) {
1560  $revRecord = new MutableRevisionRecord( $title );
1561  $revRecord->setContent( SlotRecord::MAIN, $content )
1562  ->setUser( $user )
1563  ->setTimestamp( MWTimestamp::now( TS_MW ) )
1564  ->setPageId( $title->getArticleID() )
1565  ->setParentId( $title->getLatestRevID() );
1566  return $revRecord;
1567  } else {
1568  return call_user_func( $oldCallback, $titleToCheck, $parser );
1569  }
1570  }
1571  );
1572 
1573  global $wgHooks;
1574  $wgHooks['TitleExists'][] =
1575  static function ( $titleToCheck, &$exists ) use ( $title ) {
1576  if ( $titleToCheck->equals( $title ) ) {
1577  $exists = true;
1578  }
1579  };
1580  end( $wgHooks['TitleExists'] );
1581  $key = key( $wgHooks['TitleExists'] );
1582  $linkCache = MediaWikiServices::getInstance()->getLinkCache();
1583  $linkCache->clearBadLink( $title->getPrefixedDBkey() );
1584  return new ScopedCallback( static function () use ( $title, $key, $linkCache ) {
1585  global $wgHooks;
1586  unset( $wgHooks['TitleExists'][$key] );
1587  $linkCache->clearLink( $title );
1588  } );
1589  }
1590 }
1591 
ParserOptions\setMaxIncludeSize
setMaxIncludeSize( $x)
Maximum size of template expansions, in bytes.
Definition: ParserOptions.php:410
ParserOptions\getMagicPMIDLinks
getMagicPMIDLinks()
Are magic PMID links enabled?
Definition: ParserOptions.php:773
ParserOptions
Set options of the Parser.
Definition: ParserOptions.php:44
ParserOptions\setOptionLegacy
setOptionLegacy( $name, $value)
Legacy implementation.
Definition: ParserOptions.php:223
ParserOptions\getAllowExternalImagesFrom
getAllowExternalImagesFrom()
External images to allow.
Definition: ParserOptions.php:278
ParserOptions\getWrapOutputClass
getWrapOutputClass()
Class to use to wrap output from Parser::parse()
Definition: ParserOptions.php:821
ParserOptions\getExpensiveParserFunctionLimit
getExpensiveParserFunctionLimit()
Maximum number of calls per parse to expensive parser functions.
Definition: ParserOptions.php:461
ParserOptions\setTidy
setTidy( $x)
Use tidy to cleanup output HTML?
Definition: ParserOptions.php:357
ParserOptions\getIsSectionPreview
getIsSectionPreview()
Parsing the page for a "preview" operation on a single section?
Definition: ParserOptions.php:636
$wgMaxArticleSize
$wgMaxArticleSize
Maximum article size in kilobytes.
Definition: DefaultSettings.php:2488
ParserOptions\getRemoveComments
getRemoveComments()
Remove HTML comments.
Definition: ParserOptions.php:480
ParserOptions\setAllowUnsafeRawHtml
setAllowUnsafeRawHtml( $x)
If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of...
Definition: ParserOptions.php:812
ParserOptions\disableContentConversion
disableContentConversion( $x=true)
Whether content conversion should be disabled.
Definition: ParserOptions.php:560
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:173
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:37
ParserOptions\initialiseFromUser
initialiseFromUser( $user, $lang)
Get user options.
Definition: ParserOptions.php:1323
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:1561
$wgMaxTemplateDepth
$wgMaxTemplateDepth
Maximum recursion depth for templates within templates.
Definition: DefaultSettings.php:4654
ParserOptions\getIsPreview
getIsPreview()
Parsing the page for a "preview" operation?
Definition: ParserOptions.php:619
ParserOptions\getDisableTitleConversion
getDisableTitleConversion()
Whether title conversion should be disabled.
Definition: ParserOptions.php:568
ParserOptions\setAllowExternalImages
setAllowExternalImages( $x)
Allow all external images inline?
Definition: ParserOptions.php:266
ParserOptions\setTemplateCallback
setTemplateCallback( $x)
Callback for template fetching; first argument to call_user_func().
Definition: ParserOptions.php:944
ParserOptions\setIsPreview
setIsPreview( $x)
Parsing the page for a "preview" operation?
Definition: ParserOptions.php:628
ParserOptions\setTargetLanguage
setTargetLanguage( $x)
Target language for the parse.
Definition: ParserOptions.php:393
ParserOptions\getInterfaceMessage
getInterfaceMessage()
Parsing an interface message?
Definition: ParserOptions.php:367
ParserOptions\setIsSectionPreview
setIsSectionPreview( $x)
Parsing the page for a "preview" operation on a single section?
Definition: ParserOptions.php:645
ParserOptions\getSpeculativeRevId
getSpeculativeRevId()
A guess for {{REVISIONID}}, calculated using the callback provided via setSpeculativeRevIdCallback().
Definition: ParserOptions.php:958
ParserOptions\newFromAnon
static newFromAnon()
Get a ParserOptions object for an anonymous user.
Definition: ParserOptions.php:1117
ParserOptions\setEnableImageWhitelist
setEnableImageWhitelist( $x)
Use the on-wiki external image whitelist?
Definition: ParserOptions.php:312
ParserOptions\setWrapOutputClass
setWrapOutputClass( $className)
CSS class to use to wrap output from Parser::parse()
Definition: ParserOptions.php:832
ParserOptions\setSpeculativeRevIdCallback
setSpeculativeRevIdCallback( $x)
Callback to generate a guess for {{REVISIONID}}.
Definition: ParserOptions.php:1010
ParserOptions\disableTitleConversion
disableTitleConversion( $x=true)
Whether title conversion should be disabled.
Definition: ParserOptions.php:577
ParserOptions\initDateFormat
static initDateFormat(ParserOptions $popt)
Lazy initializer for dateFormat.
Definition: ParserOptions.php:696
ParserOptions\getIsPrintable
getIsPrintable()
Parsing the printable version of the page?
Definition: ParserOptions.php:653
ParserOptions\setCurrentRevisionCallback
setCurrentRevisionCallback( $x)
Callback for current revision fetching; first argument to call_user_func().
Definition: ParserOptions.php:915
ParserOptions\setMaxTemplateDepth
setMaxTemplateDepth( $x)
Maximum recursion depth for templates within templates.
Definition: ParserOptions.php:452
$wgLang
$wgLang
Definition: Setup.php:782
ParserOptions\getMagicRFCLinks
getMagicRFCLinks()
Are magic RFC links enabled?
Definition: ParserOptions.php:782
ParserOptions\getUserLangObj
getUserLangObj()
Get the user language used by the parser for this page and split the parser cache.
Definition: ParserOptions.php:726
ParserOptions\registerWatcher
registerWatcher( $callback)
Registers a callback for tracking which ParserOptions which are used.
Definition: ParserOptions.php:1408
ParserOptions\setupFakeRevision
setupFakeRevision( $title, $content, $user)
Sets a hook to force that a page exists, and sets a current revision callback to return a revision wi...
Definition: ParserOptions.php:1554
ParserOptions\getDateFormat
getDateFormat()
Date format index.
Definition: ParserOptions.php:687
Revision
Definition: Revision.php:40
ParserOptions\setOption
setOption( $name, $value)
Set an option, generically.
Definition: ParserOptions.php:206
ParserOptions\initSpeculativeRevId
static initSpeculativeRevId(ParserOptions $popt)
Callback registered with ParserOptions::$lazyOptions, triggered by getSpeculativeRevId().
Definition: ParserOptions.php:982
ParserOptions\setNumberHeadings
setNumberHeadings( $x)
Automatically number headings?
Definition: ParserOptions.php:330
$wgHooks
$wgHooks
Global list of hooks.
Definition: DefaultSettings.php:8021
ParserOptions\getCanonicalOverrides
static getCanonicalOverrides()
Get "canonical" non-default option values.
Definition: ParserOptions.php:1309
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Definition: GlobalFunctions.php:1034
ParserOptions\getRedirectTarget
getRedirectTarget()
Get the previously-set redirect target.
Definition: ParserOptions.php:1064
ParserOptions\newFromUserAndLang
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
Definition: ParserOptions.php:1144
ParserOptions\setUserLang
setUserLang( $x)
Set the user language used by the parser for this page and split the parser cache.
Definition: ParserOptions.php:751
ParserOptions\getAllowSpecialInclusion
getAllowSpecialInclusion()
Allow inclusion of special pages?
Definition: ParserOptions.php:338
$wgAllowExternalImagesFrom
$wgAllowExternalImagesFrom
If the above is false, you can specify an exception here.
Definition: DefaultSettings.php:4700
ParserOptions\getMaxIncludeSize
getMaxIncludeSize()
Maximum size of template expansions, in bytes.
Definition: ParserOptions.php:401
ParserOptions\$mTimestamp
string null $mTimestamp
Timestamp used for {{CURRENTDAY}} etc.
Definition: ParserOptions.php:111
$wgExpensiveParserFunctionLimit
$wgExpensiveParserFunctionLimit
Maximum number of calls per parse to expensive parser functions such as PAGESINCATEGORY.
Definition: DefaultSettings.php:4816
ParserOptions\setThumbSize
setThumbSize( $x)
Thumb size preferred by the user.
Definition: ParserOptions.php:594
ParserOptions\getEnableImageWhitelist
getEnableImageWhitelist()
Use the on-wiki external image whitelist?
Definition: ParserOptions.php:301
$wgInterwikiMagic
$wgInterwikiMagic
Treat language links as magic connectors, not inline links.
Definition: DefaultSettings.php:3218
ParserOptions\setExternalLinkTarget
setExternalLinkTarget( $x)
Target attribute for external links.
Definition: ParserOptions.php:543
ParserOptions\setDateFormat
setDateFormat( $x)
Date format index.
Definition: ParserOptions.php:705
ParserOptions\getTargetLanguage
getTargetLanguage()
Target language for the parse.
Definition: ParserOptions.php:384
$title
$title
Definition: testCompression.php:38
ParserOptions\initSpeculativePageId
static initSpeculativePageId(ParserOptions $popt)
Callback registered with ParserOptions::$lazyOptions, triggered by getSpeculativePageId().
Definition: ParserOptions.php:996
ParserOptions\setAllowSpecialInclusion
setAllowSpecialInclusion( $x)
Allow inclusion of special pages?
Definition: ParserOptions.php:347
$wgMaxPPExpandDepth
$wgMaxPPExpandDepth
Definition: DefaultSettings.php:4659
ParserOptions\getDefaults
static getDefaults()
Get default option values.
Definition: ParserOptions.php:1228
ParserOptions\getExternalLinkTarget
getExternalLinkTarget()
Target attribute for external links.
Definition: ParserOptions.php:534
ParserOptions\$onAccessCallback
callable null $onAccessCallback
Function to be called when an option is accessed.
Definition: ParserOptions.php:125
$wgEnableMagicLinks
$wgEnableMagicLinks
Enable the magic links feature of automatically turning ISBN xxx, PMID xxx, RFC xxx into links.
Definition: DefaultSettings.php:4841
wfTimestampNow
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Definition: GlobalFunctions.php:1861
ParserOptions\getStubThreshold
getStubThreshold()
Thumb size preferred by the user.
Definition: ParserOptions.php:602
$wgExternalLinkTarget
$wgExternalLinkTarget
Set a default target for external links, e.g.
Definition: DefaultSettings.php:4769
ParserOptions\$options
array $options
Current values for all options that are relevant for caching.
Definition: ParserOptions.php:104
ParserOptions\getUserLang
getUserLang()
Same as getUserLangObj() but returns a string instead.
Definition: ParserOptions.php:742
ParserOptions\getPreSaveTransform
getPreSaveTransform()
Transform wiki markup when saving the page?
Definition: ParserOptions.php:670
ParserOptions\setStubThreshold
setStubThreshold( $x)
Thumb size preferred by the user.
Definition: ParserOptions.php:611
ParserOptions\$lazyOptions
static callable[] null $lazyOptions
Lazy-loaded options.
Definition: ParserOptions.php:57
ParserOptions\getOption
getOption( $name)
Fetch an option and track that is was accessed.
Definition: ParserOptions.php:146
ParserOptions\$mExtraKey
$mExtraKey
Appended to the options hash.
Definition: ParserOptions.php:138
ParserOptions\getAllowUnsafeRawHtml
getAllowUnsafeRawHtml()
If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of...
Definition: ParserOptions.php:800
ParserOptions\getDisableContentConversion
getDisableContentConversion()
Whether content conversion should be disabled.
Definition: ParserOptions.php:551
ParserOptions\optionToString
optionToString( $value)
Convert an option to a string value.
Definition: ParserOptions.php:1440
ParserOptions\matchesForCacheKey
matchesForCacheKey(ParserOptions $other)
Definition: ParserOptions.php:1387
ParserOptions\optionUsed
optionUsed( $optionName)
Called when an option is accessed.
Definition: ParserOptions.php:1420
$content
$content
Definition: router.php:76
ParserOptions\getSpeculativePageId
getSpeculativePageId()
A guess for {{PAGEID}}, calculated using the callback provided via setSpeculativeRevPageCallback().
Definition: ParserOptions.php:972
ParserOptions\setTimestamp
setTimestamp( $x)
Timestamp used for {{CURRENTDAY}} etc.
Definition: ParserOptions.php:1042
ParserOptions\setSpeculativePageIdCallback
setSpeculativePageIdCallback( $x)
Callback to generate a guess for {{PAGEID}}.
Definition: ParserOptions.php:1021
ParserOptions\setCleanSignatures
setCleanSignatures( $x)
Clean up signature texts?
Definition: ParserOptions.php:526
ParserOptions\newFromContext
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
Definition: ParserOptions.php:1156
Revision\MutableRevisionRecord
Definition: MutableRevisionRecord.php:45
ParserOptions\getCurrentRevisionCallback
getCurrentRevisionCallback()
Callback for current revision fetching; first argument to call_user_func().
Definition: ParserOptions.php:848
Hooks\runner
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Definition: Hooks.php:172
$wgEnableParserLimitReporting
$wgEnableParserLimitReporting
Whether to include the NewPP limit report as a HTML comment.
Definition: DefaultSettings.php:7876
ParserOptions\getTemplateCallback
getTemplateCallback()
Callback for template fetching; first argument to call_user_func().
Definition: ParserOptions.php:935
ParserOptions\$cacheVaryingOptionsHash
static array null $cacheVaryingOptionsHash
Specify options that are included in the cache key.
Definition: ParserOptions.php:73
ParserOptions\newCanonical
static newCanonical( $context=null, $userLang=null)
Creates a "canonical" ParserOptions object.
Definition: ParserOptions.php:1178
ParserOptions\setRemoveComments
setRemoveComments( $x)
Remove HTML comments.
Definition: ParserOptions.php:490
ParserOptions\setInterwikiMagic
setInterwikiMagic( $x)
Specify whether to extract interlanguage links.
Definition: ParserOptions.php:247
IContextSource\getUser
getUser()
ParserOptions\lazyLoadOption
lazyLoadOption( $name)
Definition: ParserOptions.php:159
ParserOptions\setRedirectTarget
setRedirectTarget( $title)
Note that setting or changing this does not make the page a redirect or change its target,...
Definition: ParserOptions.php:1054
ParserOptions\setExpensiveParserFunctionLimit
setExpensiveParserFunctionLimit( $x)
Maximum number of calls per parse to expensive parser functions.
Definition: ParserOptions.php:471
ParserOptions\getTimestamp
getTimestamp()
Timestamp used for {{CURRENTDAY}} etc.
Definition: ParserOptions.php:1030
ParserOptions\setMaxPPNodeCount
setMaxPPNodeCount( $x)
Maximum number of nodes touched by PPFrame::expand()
Definition: ParserOptions.php:427
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:57
ParserOptions\getCleanSignatures
getCleanSignatures()
Clean up signature texts?
Definition: ParserOptions.php:516
ParserOptions\getLazyOptions
static getLazyOptions()
Get lazy-loaded options.
Definition: ParserOptions.php:177
ParserOptions\$redirectTarget
Title null $redirectTarget
If the page being parsed is a redirect, this should hold the redirect target.
Definition: ParserOptions.php:133
ParserOptions\setAllowExternalImagesFrom
setAllowExternalImagesFrom( $x)
External images to allow.
Definition: ParserOptions.php:292
ParserOptions\matches
matches(ParserOptions $other)
Check if these options match that of another options set.
Definition: ParserOptions.php:1342
ParserOptions\enableLimitReport
enableLimitReport( $x=true)
Enable limit report in an HTML comment on output.
Definition: ParserOptions.php:507
Title
Represents a title within MediaWiki.
Definition: Title.php:46
ParserOptions\__construct
__construct( $user=null, $lang=null)
Definition: ParserOptions.php:1092
ParserOptions\getInterwikiMagic
getInterwikiMagic()
Whether to extract interlanguage links.
Definition: ParserOptions.php:238
ParserOptions\$mUser
User $mUser
Stored user object.
Definition: ParserOptions.php:118
ParserOptions\setInterfaceMessage
setInterfaceMessage( $x)
Parsing an interface message?
Definition: ParserOptions.php:376
ParserOptions\$defaults
static array null $defaults
Default values for all options that are relevant for caching.
Definition: ParserOptions.php:51
ParserOptions\allCacheVaryingOptions
static allCacheVaryingOptions()
Return all option keys that vary the options hash.
Definition: ParserOptions.php:1431
$wgCleanSignatures
$wgCleanSignatures
If true, removes (by substituting) templates in signatures.
Definition: DefaultSettings.php:4681
ParserOptions\getUser
getUser()
Current user.
Definition: ParserOptions.php:1082
ParserOptions\getThumbSize
getThumbSize()
Thumb size preferred by the user.
Definition: ParserOptions.php:585
ParserOptions\getMagicISBNLinks
getMagicISBNLinks()
Are magic ISBN links enabled?
Definition: ParserOptions.php:764
ParserOptions\getCacheVaryingOptionsHash
static getCacheVaryingOptionsHash()
Get cache varying options, with the name of the option in the key, and a boolean in the value which i...
Definition: ParserOptions.php:189
ParserOptions\setIsPrintable
setIsPrintable( $x)
Parsing the printable version of the page?
Definition: ParserOptions.php:662
ParserOptions\getMaxPPNodeCount
getMaxPPNodeCount()
Maximum number of nodes touched by PPFrame::expand()
Definition: ParserOptions.php:418
$wgRenderHashAppend
$wgRenderHashAppend
Append a configured value to the parser cache and the sitenotice key so that they can be kept separat...
Definition: DefaultSettings.php:2900
ParserOptions\getCurrentRevisionRecordCallback
getCurrentRevisionRecordCallback()
Callback for current revision fetching; first argument to call_user_func().
Definition: ParserOptions.php:886
ParserOptions\getMaxPPExpandDepth
getMaxPPExpandDepth()
Maximum recursion depth in PPFrame::expand()
Definition: ParserOptions.php:435
ParserOptions\clearStaticCache
static clearStaticCache()
Reset static caches.
Definition: ParserOptions.php:1210
ParserOptions\getEnableLimitReport
getEnableLimitReport()
Enable limit report in an HTML comment on output.
Definition: ParserOptions.php:498
ParserOptions\isSafeToCache
isSafeToCache(array $usedOptions=null)
Test whether these options are safe to cache.
Definition: ParserOptions.php:1528
ParserOptions\getNumberHeadings
getNumberHeadings()
Automatically number headings?
Definition: ParserOptions.php:321
ParserOptions\getMaxTemplateDepth
getMaxTemplateDepth()
Maximum recursion depth for templates within templates.
Definition: ParserOptions.php:443
ParserOptions\setPreSaveTransform
setPreSaveTransform( $x)
Transform wiki markup when saving the page?
Definition: ParserOptions.php:679
ParserOptions\$initialCacheVaryingOptionsHash
static array $initialCacheVaryingOptionsHash
Initial inCacheKey options (before hook)
Definition: ParserOptions.php:79
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:66
ParserOptions\$callbacks
static array $callbacks
Specify pseudo-options that are actually callbacks.
Definition: ParserOptions.php:92
StubObject\unstub
static unstub(&$obj)
Unstubs an object, if it is a stub object.
Definition: StubObject.php:101
ParserOptions\$initialLazyOptions
static callable[] $initialLazyOptions
Initial lazy-loaded options (before hook)
Definition: ParserOptions.php:63
$wgMaxPPNodeCount
$wgMaxPPNodeCount
A complexity limit on template expansion: the maximum number of nodes visited by PPFrame::expand()
Definition: DefaultSettings.php:4646
ParserOptions\setCurrentRevisionRecordCallback
setCurrentRevisionRecordCallback( $x)
Callback for current revision fetching; first argument to call_user_func().
Definition: ParserOptions.php:927
Language
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: Language.php:43
ParserOptions\optionsHash
optionsHash( $forOptions, $title=null)
Generate a hash string with the values set on these ParserOptions for the keys given in the array.
Definition: ParserOptions.php:1468
IContextSource\getLanguage
getLanguage()
Revision\SlotRecord
Value object representing a content slot associated with a page revision.
Definition: SlotRecord.php:40
ParserOptions\getAllowExternalImages
getAllowExternalImages()
Allow all external images inline?
Definition: ParserOptions.php:255
ParserOptions\newFromUser
static newFromUser( $user)
Get a ParserOptions object from a given user.
Definition: ParserOptions.php:1131
$wgAllowExternalImages
$wgAllowExternalImages
Whether to allow inline image pointing to other websites.
Definition: DefaultSettings.php:4686
$wgEnableImageWhitelist
$wgEnableImageWhitelist
If $wgAllowExternalImages is false, you can allow an on-wiki allow list of regular expression fragmen...
Definition: DefaultSettings.php:4713
ParserOptions\addExtraKey
addExtraKey( $key)
Extra key that should be present in the parser cache key.
Definition: ParserOptions.php:1074
$wgAllowSpecialInclusion
$wgAllowSpecialInclusion
Allow special page inclusions such as {{Special:Allpages}}.
Definition: DefaultSettings.php:8460