MediaWiki REL1_31
ParserOptions.php
Go to the documentation of this file.
1<?php
23use Wikimedia\ScopedCallback;
24
41
47 private static $defaults = null;
48
53 private static $lazyOptions = [
54 'dateformat' => [ __CLASS__, 'initDateFormat' ],
55 ];
56
61 private static $inCacheKey = [
62 'dateformat' => true,
63 'numberheadings' => true,
64 'thumbsize' => true,
65 'stubthreshold' => true,
66 'printable' => true,
67 'userlang' => true,
68 ];
69
74 private $options;
75
81 private $mTimestamp;
82
88 private $mUser;
89
95 private $onAccessCallback = null;
96
103 private $redirectTarget = null;
104
108 private $mExtraKey = '';
109
121 public function getOption( $name ) {
122 if ( !array_key_exists( $name, $this->options ) ) {
123 throw new InvalidArgumentException( "Unknown parser option $name" );
124 }
125
126 if ( isset( self::$lazyOptions[$name] ) && $this->options[$name] === null ) {
127 $this->options[$name] = call_user_func( self::$lazyOptions[$name], $this, $name );
128 }
129 if ( !empty( self::$inCacheKey[$name] ) ) {
130 $this->optionUsed( $name );
131 }
132 return $this->options[$name];
133 }
134
143 public function setOption( $name, $value ) {
144 if ( !array_key_exists( $name, $this->options ) ) {
145 throw new InvalidArgumentException( "Unknown parser option $name" );
146 }
147 $old = $this->options[$name];
148 $this->options[$name] = $value;
149 return $old;
150 }
151
160 protected function setOptionLegacy( $name, $value ) {
161 if ( !array_key_exists( $name, $this->options ) ) {
162 throw new InvalidArgumentException( "Unknown parser option $name" );
163 }
164 return wfSetVar( $this->options[$name], $value );
165 }
166
175 public function getInterwikiMagic() {
176 return $this->getOption( 'interwikiMagic' );
177 }
178
184 public function setInterwikiMagic( $x ) {
185 return $this->setOptionLegacy( 'interwikiMagic', $x );
186 }
187
192 public function getAllowExternalImages() {
193 return $this->getOption( 'allowExternalImages' );
194 }
195
201 public function setAllowExternalImages( $x ) {
202 return $this->setOptionLegacy( 'allowExternalImages', $x );
203 }
204
212 public function getAllowExternalImagesFrom() {
213 return $this->getOption( 'allowExternalImagesFrom' );
214 }
215
224 public function setAllowExternalImagesFrom( $x ) {
225 return $this->setOptionLegacy( 'allowExternalImagesFrom', $x );
226 }
227
232 public function getEnableImageWhitelist() {
233 return $this->getOption( 'enableImageWhitelist' );
234 }
235
241 public function setEnableImageWhitelist( $x ) {
242 return $this->setOptionLegacy( 'enableImageWhitelist', $x );
243 }
244
249 public function getNumberHeadings() {
250 return $this->getOption( 'numberheadings' );
251 }
252
258 public function setNumberHeadings( $x ) {
259 return $this->setOptionLegacy( 'numberheadings', $x );
260 }
261
266 public function getAllowSpecialInclusion() {
267 return $this->getOption( 'allowSpecialInclusion' );
268 }
269
275 public function setAllowSpecialInclusion( $x ) {
276 return $this->setOptionLegacy( 'allowSpecialInclusion', $x );
277 }
278
283 public function getTidy() {
284 return $this->getOption( 'tidy' );
285 }
286
292 public function setTidy( $x ) {
293 return $this->setOptionLegacy( 'tidy', $x );
294 }
295
300 public function getInterfaceMessage() {
301 return $this->getOption( 'interfaceMessage' );
302 }
303
309 public function setInterfaceMessage( $x ) {
310 return $this->setOptionLegacy( 'interfaceMessage', $x );
311 }
312
317 public function getTargetLanguage() {
318 return $this->getOption( 'targetLanguage' );
319 }
320
326 public function setTargetLanguage( $x ) {
327 return $this->setOption( 'targetLanguage', $x );
328 }
329
334 public function getMaxIncludeSize() {
335 return $this->getOption( 'maxIncludeSize' );
336 }
337
343 public function setMaxIncludeSize( $x ) {
344 return $this->setOptionLegacy( 'maxIncludeSize', $x );
345 }
346
351 public function getMaxPPNodeCount() {
352 return $this->getOption( 'maxPPNodeCount' );
353 }
354
360 public function setMaxPPNodeCount( $x ) {
361 return $this->setOptionLegacy( 'maxPPNodeCount', $x );
362 }
363
368 public function getMaxGeneratedPPNodeCount() {
369 return $this->getOption( 'maxGeneratedPPNodeCount' );
370 }
371
377 public function setMaxGeneratedPPNodeCount( $x ) {
378 return $this->setOptionLegacy( 'maxGeneratedPPNodeCount', $x );
379 }
380
385 public function getMaxPPExpandDepth() {
386 return $this->getOption( 'maxPPExpandDepth' );
387 }
388
393 public function getMaxTemplateDepth() {
394 return $this->getOption( 'maxTemplateDepth' );
395 }
396
402 public function setMaxTemplateDepth( $x ) {
403 return $this->setOptionLegacy( 'maxTemplateDepth', $x );
404 }
405
412 return $this->getOption( 'expensiveParserFunctionLimit' );
413 }
414
421 public function setExpensiveParserFunctionLimit( $x ) {
422 return $this->setOptionLegacy( 'expensiveParserFunctionLimit', $x );
423 }
424
430 public function getRemoveComments() {
431 return $this->getOption( 'removeComments' );
432 }
433
440 public function setRemoveComments( $x ) {
441 return $this->setOptionLegacy( 'removeComments', $x );
442 }
443
448 public function getEnableLimitReport() {
449 return $this->getOption( 'enableLimitReport' );
450 }
451
457 public function enableLimitReport( $x = true ) {
458 return $this->setOptionLegacy( 'enableLimitReport', $x );
459 }
460
466 public function getCleanSignatures() {
467 return $this->getOption( 'cleanSignatures' );
468 }
469
476 public function setCleanSignatures( $x ) {
477 return $this->setOptionLegacy( 'cleanSignatures', $x );
478 }
479
484 public function getExternalLinkTarget() {
485 return $this->getOption( 'externalLinkTarget' );
486 }
487
493 public function setExternalLinkTarget( $x ) {
494 return $this->setOptionLegacy( 'externalLinkTarget', $x );
495 }
496
501 public function getDisableContentConversion() {
502 return $this->getOption( 'disableContentConversion' );
503 }
504
510 public function disableContentConversion( $x = true ) {
511 return $this->setOptionLegacy( 'disableContentConversion', $x );
512 }
513
518 public function getDisableTitleConversion() {
519 return $this->getOption( 'disableTitleConversion' );
520 }
521
527 public function disableTitleConversion( $x = true ) {
528 return $this->setOptionLegacy( 'disableTitleConversion', $x );
529 }
530
535 public function getThumbSize() {
536 return $this->getOption( 'thumbsize' );
537 }
538
544 public function setThumbSize( $x ) {
545 return $this->setOptionLegacy( 'thumbsize', $x );
546 }
547
552 public function getStubThreshold() {
553 return $this->getOption( 'stubthreshold' );
554 }
555
561 public function setStubThreshold( $x ) {
562 return $this->setOptionLegacy( 'stubthreshold', $x );
563 }
564
569 public function getIsPreview() {
570 return $this->getOption( 'isPreview' );
571 }
572
578 public function setIsPreview( $x ) {
579 return $this->setOptionLegacy( 'isPreview', $x );
580 }
581
586 public function getIsSectionPreview() {
587 return $this->getOption( 'isSectionPreview' );
588 }
589
595 public function setIsSectionPreview( $x ) {
596 return $this->setOptionLegacy( 'isSectionPreview', $x );
597 }
598
603 public function getIsPrintable() {
604 return $this->getOption( 'printable' );
605 }
606
612 public function setIsPrintable( $x ) {
613 return $this->setOptionLegacy( 'printable', $x );
614 }
615
620 public function getPreSaveTransform() {
621 return $this->getOption( 'preSaveTransform' );
622 }
623
629 public function setPreSaveTransform( $x ) {
630 return $this->setOptionLegacy( 'preSaveTransform', $x );
631 }
632
637 public function getDateFormat() {
638 return $this->getOption( 'dateformat' );
639 }
640
644 private static function initDateFormat( $popt ) {
645 return $popt->mUser->getDatePreference();
646 }
647
653 public function setDateFormat( $x ) {
654 return $this->setOptionLegacy( 'dateformat', $x );
655 }
656
674 public function getUserLangObj() {
675 return $this->getOption( 'userlang' );
676 }
677
690 public function getUserLang() {
691 return $this->getUserLangObj()->getCode();
692 }
693
699 public function setUserLang( $x ) {
700 if ( is_string( $x ) ) {
701 $x = Language::factory( $x );
702 }
703
704 return $this->setOptionLegacy( 'userlang', $x );
705 }
706
712 public function getMagicISBNLinks() {
713 return $this->getOption( 'magicISBNLinks' );
714 }
715
721 public function getMagicPMIDLinks() {
722 return $this->getOption( 'magicPMIDLinks' );
723 }
729 public function getMagicRFCLinks() {
730 return $this->getOption( 'magicRFCLinks' );
731 }
732
747 public function getAllowUnsafeRawHtml() {
748 return $this->getOption( 'allowUnsafeRawHtml' );
749 }
750
759 public function setAllowUnsafeRawHtml( $x ) {
760 return $this->setOptionLegacy( 'allowUnsafeRawHtml', $x );
761 }
762
768 public function getWrapOutputClass() {
769 return $this->getOption( 'wrapclass' );
770 }
771
779 public function setWrapOutputClass( $className ) {
780 if ( $className === true ) { // DWIM, they probably want the default class name
781 $className = 'mw-parser-output';
782 }
783 if ( $className === false ) {
784 wfDeprecated( __METHOD__ . '( false )', '1.31' );
785 }
786 return $this->setOption( 'wrapclass', $className );
787 }
788
794 public function getCurrentRevisionCallback() {
795 return $this->getOption( 'currentRevisionCallback' );
796 }
797
804 public function setCurrentRevisionCallback( $x ) {
805 return $this->setOptionLegacy( 'currentRevisionCallback', $x );
806 }
807
812 public function getTemplateCallback() {
813 return $this->getOption( 'templateCallback' );
814 }
815
821 public function setTemplateCallback( $x ) {
822 return $this->setOptionLegacy( 'templateCallback', $x );
823 }
824
830 public function getSpeculativeRevIdCallback() {
831 return $this->getOption( 'speculativeRevIdCallback' );
832 }
833
840 public function setSpeculativeRevIdCallback( $x ) {
841 return $this->setOptionLegacy( 'speculativeRevIdCallback', $x );
842 }
843
850 public function getTimestamp() {
851 if ( !isset( $this->mTimestamp ) ) {
852 $this->mTimestamp = wfTimestampNow();
853 }
854 return $this->mTimestamp;
855 }
856
862 public function setTimestamp( $x ) {
863 return wfSetVar( $this->mTimestamp, $x );
864 }
865
871 public function getEditSection() {
872 wfDeprecated( __METHOD__, '1.31' );
873 return true;
874 }
875
882 public function setEditSection( $x ) {
883 wfDeprecated( __METHOD__, '1.31' );
884 return true;
885 }
886
897 function setRedirectTarget( $title ) {
898 $this->redirectTarget = $title;
899 }
900
907 function getRedirectTarget() {
908 return $this->redirectTarget;
909 }
910
917 public function addExtraKey( $key ) {
918 $this->mExtraKey .= '!' . $key;
919 }
920
925 public function getUser() {
926 return $this->mUser;
927 }
928
936 public function __construct( $user = null, $lang = null ) {
937 if ( $user === null ) {
939 if ( $wgUser === null ) {
940 $user = new User;
941 } else {
942 $user = $wgUser;
943 }
944 }
945 if ( $lang === null ) {
948 $wgLang->_unstub();
949 }
950 $lang = $wgLang;
951 }
952 $this->initialiseFromUser( $user, $lang );
953 }
954
963 public static function newFromAnon() {
965 return new ParserOptions( new User, $wgContLang );
966 }
967
978 public static function newFromUser( $user ) {
979 return new ParserOptions( $user );
980 }
981
992 public static function newFromUserAndLang( User $user, Language $lang ) {
993 return new ParserOptions( $user, $lang );
994 }
995
1005 public static function newFromContext( IContextSource $context ) {
1006 return new ParserOptions( $context->getUser(), $context->getLanguage() );
1007 }
1008
1020 public static function newCanonical( User $user = null, $lang = null ) {
1021 $ret = new ParserOptions( $user, $lang );
1022 foreach ( self::getCanonicalOverrides() as $k => $v ) {
1023 $ret->setOption( $k, $v );
1024 }
1025 return $ret;
1026 }
1027
1037 private static function getDefaults() {
1044
1045 if ( self::$defaults === null ) {
1046 // *UPDATE* ParserOptions::matches() if any of this changes as needed
1047 self::$defaults = [
1048 'dateformat' => null,
1049 'tidy' => false,
1050 'interfaceMessage' => false,
1051 'targetLanguage' => null,
1052 'removeComments' => true,
1053 'enableLimitReport' => false,
1054 'preSaveTransform' => true,
1055 'isPreview' => false,
1056 'isSectionPreview' => false,
1057 'printable' => false,
1058 'allowUnsafeRawHtml' => true,
1059 'wrapclass' => 'mw-parser-output',
1060 'currentRevisionCallback' => [ Parser::class, 'statelessFetchRevision' ],
1061 'templateCallback' => [ Parser::class, 'statelessFetchTemplate' ],
1062 'speculativeRevIdCallback' => null,
1063 ];
1064
1065 Hooks::run( 'ParserOptionsRegister', [
1066 &self::$defaults,
1067 &self::$inCacheKey,
1068 &self::$lazyOptions,
1069 ] );
1070
1071 ksort( self::$inCacheKey );
1072 }
1073
1074 // Unit tests depend on being able to modify the globals at will
1075 return self::$defaults + [
1076 'interwikiMagic' => $wgInterwikiMagic,
1077 'allowExternalImages' => $wgAllowExternalImages,
1078 'allowExternalImagesFrom' => $wgAllowExternalImagesFrom,
1079 'enableImageWhitelist' => $wgEnableImageWhitelist,
1080 'allowSpecialInclusion' => $wgAllowSpecialInclusion,
1081 'maxIncludeSize' => $wgMaxArticleSize * 1024,
1082 'maxPPNodeCount' => $wgMaxPPNodeCount,
1083 'maxGeneratedPPNodeCount' => $wgMaxGeneratedPPNodeCount,
1084 'maxPPExpandDepth' => $wgMaxPPExpandDepth,
1085 'maxTemplateDepth' => $wgMaxTemplateDepth,
1086 'expensiveParserFunctionLimit' => $wgExpensiveParserFunctionLimit,
1087 'externalLinkTarget' => $wgExternalLinkTarget,
1088 'cleanSignatures' => $wgCleanSignatures,
1089 'disableContentConversion' => $wgDisableLangConversion,
1090 'disableTitleConversion' => $wgDisableLangConversion || $wgDisableTitleConversion,
1091 'magicISBNLinks' => $wgEnableMagicLinks['ISBN'],
1092 'magicPMIDLinks' => $wgEnableMagicLinks['PMID'],
1093 'magicRFCLinks' => $wgEnableMagicLinks['RFC'],
1094 'numberheadings' => User::getDefaultOption( 'numberheadings' ),
1095 'thumbsize' => User::getDefaultOption( 'thumbsize' ),
1096 'stubthreshold' => 0,
1097 'userlang' => $wgContLang,
1098 ];
1099 }
1100
1110 private static function getCanonicalOverrides() {
1112
1113 return [
1114 'tidy' => true,
1115 'enableLimitReport' => $wgEnableParserLimitReporting,
1116 ];
1117 }
1118
1125 private function initialiseFromUser( $user, $lang ) {
1126 $this->options = self::getDefaults();
1127
1128 $this->mUser = $user;
1129 $this->options['numberheadings'] = $user->getOption( 'numberheadings' );
1130 $this->options['thumbsize'] = $user->getOption( 'thumbsize' );
1131 $this->options['stubthreshold'] = $user->getStubThreshold();
1132 $this->options['userlang'] = $lang;
1133 }
1134
1144 public function matches( ParserOptions $other ) {
1145 // Populate lazy options
1146 foreach ( self::$lazyOptions as $name => $callback ) {
1147 if ( $this->options[$name] === null ) {
1148 $this->options[$name] = call_user_func( $callback, $this, $name );
1149 }
1150 if ( $other->options[$name] === null ) {
1151 $other->options[$name] = call_user_func( $callback, $other, $name );
1152 }
1153 }
1154
1155 // Compare most options
1156 $options = array_keys( $this->options );
1157 $options = array_diff( $options, [
1158 'enableLimitReport', // only affects HTML comments
1159 ] );
1160 foreach ( $options as $option ) {
1161 $o1 = $this->optionToString( $this->options[$option] );
1162 $o2 = $this->optionToString( $other->options[$option] );
1163 if ( $o1 !== $o2 ) {
1164 return false;
1165 }
1166 }
1167
1168 // Compare most other fields
1169 $fields = array_keys( get_class_vars( __CLASS__ ) );
1170 $fields = array_diff( $fields, [
1171 'defaults', // static
1172 'lazyOptions', // static
1173 'inCacheKey', // static
1174 'options', // Already checked above
1175 'onAccessCallback', // only used for ParserOutput option tracking
1176 ] );
1177 foreach ( $fields as $field ) {
1178 if ( !is_object( $this->$field ) && $this->$field !== $other->$field ) {
1179 return false;
1180 }
1181 }
1182
1183 return true;
1184 }
1185
1191 public function registerWatcher( $callback ) {
1192 $this->onAccessCallback = $callback;
1193 }
1194
1203 public function optionUsed( $optionName ) {
1204 if ( $this->onAccessCallback ) {
1205 call_user_func( $this->onAccessCallback, $optionName );
1206 }
1207 }
1208
1216 public static function legacyOptions() {
1217 wfDeprecated( __METHOD__, '1.30' );
1218 return [
1219 'stubthreshold',
1220 'numberheadings',
1221 'userlang',
1222 'thumbsize',
1223 'editsection',
1224 'printable'
1225 ];
1226 }
1227
1233 public static function allCacheVaryingOptions() {
1234 // Trigger a call to the 'ParserOptionsRegister' hook if it hasn't
1235 // already been called.
1236 if ( self::$defaults === null ) {
1237 self::getDefaults();
1238 }
1239 return array_keys( array_filter( self::$inCacheKey ) );
1240 }
1241
1247 private function optionToString( $value ) {
1248 if ( $value === true ) {
1249 return '1';
1250 } elseif ( $value === false ) {
1251 return '0';
1252 } elseif ( $value === null ) {
1253 return '';
1254 } elseif ( $value instanceof Language ) {
1255 return $value->getCode();
1256 } elseif ( is_array( $value ) ) {
1257 return '[' . implode( ',', array_map( [ $this, 'optionToString' ], $value ) ) . ']';
1258 } else {
1259 return (string)$value;
1260 }
1261 }
1262
1275 public function optionsHash( $forOptions, $title = null ) {
1277
1279 $defaults = self::getCanonicalOverrides() + self::getDefaults();
1280 $inCacheKey = self::$inCacheKey;
1281
1282 // We only include used options with non-canonical values in the key
1283 // so adding a new option doesn't invalidate the entire parser cache.
1284 // The drawback to this is that changing the default value of an option
1285 // requires manual invalidation of existing cache entries, as mentioned
1286 // in the docs on the relevant methods and hooks.
1287 $values = [];
1288 foreach ( $inCacheKey as $option => $include ) {
1289 if ( $include && in_array( $option, $forOptions, true ) ) {
1290 $v = $this->optionToString( $options[$option] );
1291 $d = $this->optionToString( $defaults[$option] );
1292 if ( $v !== $d ) {
1293 $values[] = "$option=$v";
1294 }
1295 }
1296 }
1297
1298 $confstr = $values ? implode( '!', $values ) : 'canonical';
1299
1300 // add in language specific options, if any
1301 // @todo FIXME: This is just a way of retrieving the url/user preferred variant
1302 if ( !is_null( $title ) ) {
1303 $confstr .= $title->getPageLanguage()->getExtraHashOptions();
1304 } else {
1306 $confstr .= $wgContLang->getExtraHashOptions();
1307 }
1308
1309 $confstr .= $wgRenderHashAppend;
1310
1311 if ( $this->mExtraKey != '' ) {
1312 $confstr .= $this->mExtraKey;
1313 }
1314
1315 // Give a chance for extensions to modify the hash, if they have
1316 // extra options or other effects on the parser cache.
1317 Hooks::run( 'PageRenderingHash', [ &$confstr, $this->getUser(), &$forOptions ] );
1318
1319 // Make it a valid memcached key fragment
1320 $confstr = str_replace( ' ', '_', $confstr );
1321
1322 return $confstr;
1323 }
1324
1330 public function isSafeToCache() {
1331 $defaults = self::getCanonicalOverrides() + self::getDefaults();
1332 foreach ( $this->options as $option => $value ) {
1333 if ( empty( self::$inCacheKey[$option] ) ) {
1334 $v = $this->optionToString( $value );
1335 $d = $this->optionToString( $defaults[$option] );
1336 if ( $v !== $d ) {
1337 return false;
1338 }
1339 }
1340 }
1341 return true;
1342 }
1343
1354 public function setupFakeRevision( $title, $content, $user ) {
1355 $oldCallback = $this->setCurrentRevisionCallback(
1356 function (
1357 $titleToCheck, $parser = false ) use ( $title, $content, $user, &$oldCallback
1358 ) {
1359 if ( $titleToCheck->equals( $title ) ) {
1360 return new Revision( [
1361 'page' => $title->getArticleID(),
1362 'user_text' => $user->getName(),
1363 'user' => $user->getId(),
1364 'parent_id' => $title->getLatestRevID(),
1365 'title' => $title,
1366 'content' => $content
1367 ] );
1368 } else {
1369 return call_user_func( $oldCallback, $titleToCheck, $parser );
1370 }
1371 }
1372 );
1373
1375 $wgHooks['TitleExists'][] =
1376 function ( $titleToCheck, &$exists ) use ( $title ) {
1377 if ( $titleToCheck->equals( $title ) ) {
1378 $exists = true;
1379 }
1380 };
1381 end( $wgHooks['TitleExists'] );
1382 $key = key( $wgHooks['TitleExists'] );
1383 LinkCache::singleton()->clearBadLink( $title->getPrefixedDBkey() );
1384 return new ScopedCallback( function () use ( $title, $key ) {
1386 unset( $wgHooks['TitleExists'][$key] );
1387 LinkCache::singleton()->clearLink( $title );
1388 } );
1389 }
1390}
1391
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgMaxTemplateDepth
Maximum recursion depth for templates within templates.
$wgMaxPPNodeCount
A complexity limit on template expansion: the maximum number of nodes visited by PPFrame::expand()
$wgMaxArticleSize
Maximum article size in kilobytes.
$wgMaxGeneratedPPNodeCount
A complexity limit on template expansion: the maximum number of elements generated by Preprocessor::p...
$wgEnableParserLimitReporting
Whether to include the NewPP limit report as a HTML comment.
$wgEnableImageWhitelist
If $wgAllowExternalImages is false, you can allow an on-wiki whitelist of regular expression fragment...
$wgCleanSignatures
If true, removes (by substituting) templates in signatures.
$wgRenderHashAppend
Append a configured value to the parser cache and the sitenotice key so that they can be kept separat...
$wgMaxPPExpandDepth
$wgDisableLangConversion
Whether to enable language variant conversion.
$wgAllowSpecialInclusion
Allow special page inclusions such as {{Special:Allpages}}.
$wgAllowExternalImagesFrom
If the above is false, you can specify an exception here.
$wgInterwikiMagic
Treat language links as magic connectors, not inline links.
$wgAllowExternalImages
Whether to allow inline image pointing to other websites.
$wgEnableMagicLinks
Enable the magic links feature of automatically turning ISBN xxx, PMID xxx, RFC xxx into links.
$wgExternalLinkTarget
Set a default target for external links, e.g.
$wgExpensiveParserFunctionLimit
Maximum number of calls per parse to expensive parser functions such as PAGESINCATEGORY.
$wgDisableTitleConversion
Whether to enable language variant conversion for links.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
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...
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
$wgUser
Definition Setup.php:902
Internationalisation code.
Definition Language.php:35
Set options of the Parser.
setAllowExternalImagesFrom( $x)
External images to allow.
disableTitleConversion( $x=true)
Whether title conversion should be disabled.
setIsSectionPreview( $x)
Parsing the page for a "preview" operation on a single section?
setIsPrintable( $x)
Parsing the printable version of the page?
getRedirectTarget()
Get the previously-set redirect target.
setAllowUnsafeRawHtml( $x)
If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of...
static newCanonical(User $user=null, $lang=null)
Creates a "canonical" ParserOptions object.
getTidy()
Use tidy to cleanup output HTML?
setIsPreview( $x)
Parsing the page for a "preview" operation?
setDateFormat( $x)
Date format index.
static initDateFormat( $popt)
Lazy initializer for dateFormat.
getSpeculativeRevIdCallback()
Callback to generate a guess for {{REVISIONID}}.
enableLimitReport( $x=true)
Enable limit report in an HTML comment on output.
setTidy( $x)
Use tidy to cleanup output HTML?
optionToString( $value)
Convert an option to a string value.
callable null $onAccessCallback
Function to be called when an option is accessed.
getAllowExternalImages()
Allow all external images inline?
setNumberHeadings( $x)
Automatically number headings?
matches(ParserOptions $other)
Check if these options match that of another options set.
getMaxIncludeSize()
Maximum size of template expansions, in bytes.
setStubThreshold( $x)
Thumb size preferred by the user.
setTemplateCallback( $x)
Callback for template fetching; first argument to call_user_func().
setAllowExternalImages( $x)
Allow all external images inline?
getUserLangObj()
Get the user language used by the parser for this page and split the parser cache.
setMaxIncludeSize( $x)
Maximum size of template expansions, in bytes.
getEditSection()
Create "edit section" links?
static getCanonicalOverrides()
Get "canonical" non-default option values.
getEnableImageWhitelist()
Use the on-wiki external image whitelist?
getTargetLanguage()
Target language for the parse.
getAllowExternalImagesFrom()
External images to allow.
getCurrentRevisionCallback()
Callback for current revision fetching; first argument to call_user_func().
getIsSectionPreview()
Parsing the page for a "preview" operation on a single section?
getDisableContentConversion()
Whether content conversion should be disabled.
setInterfaceMessage( $x)
Parsing an interface message?
setTimestamp( $x)
Timestamp used for {{CURRENTDAY}} etc.
getMaxPPExpandDepth()
Maximum recursion depth in PPFrame::expand()
getExpensiveParserFunctionLimit()
Maximum number of calls per parse to expensive parser functions.
getAllowUnsafeRawHtml()
If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of...
getNumberHeadings()
Automatically number headings?
setCurrentRevisionCallback( $x)
Callback for current revision fetching; first argument to call_user_func().
getIsPreview()
Parsing the page for a "preview" operation?
static getDefaults()
Get default option values.
setOptionLegacy( $name, $value)
Legacy implementation.
setMaxTemplateDepth( $x)
Maximum recursion depth for templates within templates.
setEnableImageWhitelist( $x)
Use the on-wiki external image whitelist?
getPreSaveTransform()
Transform wiki markup when saving the page?
setWrapOutputClass( $className)
CSS class to use to wrap output from Parser::parse()
User $mUser
Stored user object.
getUser()
Current user.
optionUsed( $optionName)
Called when an option is accessed.
setRedirectTarget( $title)
Set the redirect target.
getWrapOutputClass()
Class to use to wrap output from Parser::parse()
getIsPrintable()
Parsing the printable version of the page?
getStubThreshold()
Thumb size preferred by the user.
disableContentConversion( $x=true)
Whether content conversion should be disabled.
initialiseFromUser( $user, $lang)
Get user options.
getOption( $name)
Fetch an option, generically.
setThumbSize( $x)
Thumb size preferred by the user.
optionsHash( $forOptions, $title=null)
Generate a hash string with the values set on these ParserOptions for the keys given in the array.
$mExtraKey
Appended to the options hash.
setAllowSpecialInclusion( $x)
Allow inclusion of special pages?
setOption( $name, $value)
Set an option, generically.
getMaxTemplateDepth()
Maximum recursion depth for templates within templates.
getAllowSpecialInclusion()
Allow inclusion of special pages?
setTargetLanguage( $x)
Target language for the parse.
string null $mTimestamp
Timestamp used for {{CURRENTDAY}} etc.
getMagicRFCLinks()
Are magic RFC links enabled?
setupFakeRevision( $title, $content, $user)
Sets a hook to force that a page exists, and sets a current revision callback to return a revision wi...
getMagicPMIDLinks()
Are magic PMID links enabled?
static legacyOptions()
Returns the full array of options that would have been used by in 1.16.
static array $inCacheKey
Specify options that are included in the cache key.
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
static callback[] $lazyOptions
Lazy-loaded options.
registerWatcher( $callback)
Registers a callback for tracking which ParserOptions which are used.
getCleanSignatures()
Clean up signature texts?
addExtraKey( $key)
Extra key that should be present in the parser cache key.
setInterwikiMagic( $x)
Specify whether to extract interlanguage links.
static newFromAnon()
Get a ParserOptions object for an anonymous user.
setUserLang( $x)
Set the user language used by the parser for this page and split the parser cache.
static newFromUser( $user)
Get a ParserOptions object from a given user.
getUserLang()
Same as getUserLangObj() but returns a string instead.
getDateFormat()
Date format index.
setExternalLinkTarget( $x)
Target attribute for external links.
getMaxGeneratedPPNodeCount()
Maximum number of nodes generated by Preprocessor::preprocessToObj()
array $options
Current values for all options that are relevant for caching.
getRemoveComments()
Remove HTML comments.
setRemoveComments( $x)
Remove HTML comments.
Title null $redirectTarget
If the page being parsed is a redirect, this should hold the redirect target.
setMaxGeneratedPPNodeCount( $x)
Maximum number of nodes generated by Preprocessor::preprocessToObj()
getMaxPPNodeCount()
Maximum number of nodes touched by PPFrame::expand()
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
getEnableLimitReport()
Enable limit report in an HTML comment on output.
getExternalLinkTarget()
Target attribute for external links.
getMagicISBNLinks()
Are magic ISBN links enabled?
getThumbSize()
Thumb size preferred by the user.
getInterwikiMagic()
Whether to extract interlanguage links.
__construct( $user=null, $lang=null)
setEditSection( $x)
Create "edit section" links?
getTimestamp()
Timestamp used for {{CURRENTDAY}} etc.
getTemplateCallback()
Callback for template fetching; first argument to call_user_func().
setSpeculativeRevIdCallback( $x)
Callback to generate a guess for {{REVISIONID}}.
isSafeToCache()
Test whether these options are safe to cache.
getDisableTitleConversion()
Whether title conversion should be disabled.
getInterfaceMessage()
Parsing an interface message?
static allCacheVaryingOptions()
Return all option keys that vary the options hash.
setExpensiveParserFunctionLimit( $x)
Maximum number of calls per parse to expensive parser functions.
setPreSaveTransform( $x)
Transform wiki markup when saving the page?
setMaxPPNodeCount( $x)
Maximum number of nodes touched by PPFrame::expand()
static array null $defaults
Default values for all options that are relevant for caching.
setCleanSignatures( $x)
Clean up signature texts?
static isRealObject( $obj)
Returns a bool value whenever $obj is a stub object.
Represents a title within MediaWiki.
Definition Title.php:39
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:53
static getDefaultOption( $opt)
Get a given default option value.
Definition User.php:1762
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition design.txt:57
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
Definition design.txt:26
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition design.txt:56
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
the array() calling protocol came about after MediaWiki 1.4rc1.
do that in ParserLimitReportFormat instead $parser
Definition hooks.txt:2603
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:2001
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition hooks.txt:2811
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:964
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition hooks.txt:2005
$wgHooks['ArticleShow'][]
Definition hooks.txt:108
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:302
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition hooks.txt:247
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
Interface for objects which can provide a MediaWiki context on request.
if(!isset( $args[0])) $lang