Go to the documentation of this file.
25 use Wikimedia\ScopedCallback;
63 'dateformat' => [ __CLASS__,
'initDateFormat' ],
64 'speculativeRevId' => [ __CLASS__,
'initSpeculativeRevId' ],
73 'numberheadings' =>
true,
75 'stubthreshold' =>
true,
133 throw new InvalidArgumentException(
"Unknown parser option $name" );
136 if ( isset( self::$lazyOptions[
$name] ) && $this->
options[$name] ===
null ) {
139 if ( !empty( self::$inCacheKey[
$name] ) ) {
155 throw new InvalidArgumentException(
"Unknown parser option $name" );
172 throw new InvalidArgumentException(
"Unknown parser option $name" );
186 return $this->
getOption(
'interwikiMagic' );
203 return $this->
getOption(
'allowExternalImages' );
223 return $this->
getOption(
'allowExternalImagesFrom' );
243 return $this->
getOption(
'enableImageWhitelist' );
260 return $this->
getOption(
'numberheadings' );
277 return $this->
getOption(
'allowSpecialInclusion' );
311 return $this->
getOption(
'interfaceMessage' );
328 return $this->
getOption(
'targetLanguage' );
337 return $this->
setOption(
'targetLanguage', $x );
345 return $this->
getOption(
'maxIncludeSize' );
362 return $this->
getOption(
'maxPPNodeCount' );
379 return $this->
getOption(
'maxGeneratedPPNodeCount' );
396 return $this->
getOption(
'maxPPExpandDepth' );
404 return $this->
getOption(
'maxTemplateDepth' );
422 return $this->
getOption(
'expensiveParserFunctionLimit' );
441 return $this->
getOption(
'removeComments' );
459 return $this->
getOption(
'enableLimitReport' );
477 return $this->
getOption(
'cleanSignatures' );
495 return $this->
getOption(
'externalLinkTarget' );
512 return $this->
getOption(
'disableContentConversion' );
529 return $this->
getOption(
'disableTitleConversion' );
563 return $this->
getOption(
'stubthreshold' );
597 return $this->
getOption(
'isSectionPreview' );
631 return $this->
getOption(
'preSaveTransform' );
657 return $popt->mUser->getDatePreference();
712 if ( is_string( $x ) ) {
725 return $this->
getOption(
'magicISBNLinks' );
734 return $this->
getOption(
'magicPMIDLinks' );
743 return $this->
getOption(
'magicRFCLinks' );
761 return $this->
getOption(
'allowUnsafeRawHtml' );
793 if ( $className ===
true ) {
794 $className =
'mw-parser-output';
796 if ( $className ===
false ) {
799 return $this->
setOption(
'wrapclass', $className );
808 return $this->
getOption(
'currentRevisionCallback' );
826 return $this->
getOption(
'templateCallback' );
849 return $this->
getOption(
'speculativeRevId' );
859 $cb = $popt->
getOption(
'speculativeRevIdCallback' );
860 $id = $cb ? $cb() :
null;
873 return $this->
getOption(
'speculativeRevIdCallback' );
883 $this->
setOption(
'speculativeRevId',
null );
894 if ( !isset( $this->mTimestamp ) ) {
906 return wfSetVar( $this->mTimestamp, $x );
941 $this->redirectTarget =
$title;
961 $this->mExtraKey .=
'!' . $key;
979 if (
$user ===
null ) {
981 if ( $wgUser ===
null ) {
987 if (
$lang ===
null ) {
1006 MediaWikiServices::getInstance()->getContentLanguage() );
1067 } elseif (
$context ===
'canonical' ) {
1072 throw new InvalidArgumentException(
1073 '$context must be an IContextSource, the string "canonical", a User, or null'
1077 foreach ( self::getCanonicalOverrides()
as $k => $v ) {
1078 $ret->setOption( $k, $v );
1100 if ( self::$defaults ===
null ) {
1103 'dateformat' =>
null,
1105 'interfaceMessage' =>
false,
1106 'targetLanguage' =>
null,
1107 'removeComments' =>
true,
1108 'enableLimitReport' =>
false,
1109 'preSaveTransform' =>
true,
1110 'isPreview' =>
false,
1111 'isSectionPreview' =>
false,
1112 'printable' =>
false,
1113 'allowUnsafeRawHtml' =>
true,
1114 'wrapclass' =>
'mw-parser-output',
1115 'currentRevisionCallback' => [
Parser::class,
'statelessFetchRevision' ],
1116 'templateCallback' => [
Parser::class,
'statelessFetchTemplate' ],
1117 'speculativeRevIdCallback' =>
null,
1118 'speculativeRevId' =>
null,
1124 &self::$lazyOptions,
1127 ksort( self::$inCacheKey );
1131 return self::$defaults + [
1152 'stubthreshold' => 0,
1153 'userlang' => MediaWikiServices::getInstance()->getContentLanguage(),
1183 $this->mUser =
$user;
1184 $this->
options[
'numberheadings'] =
$user->getOption(
'numberheadings' );
1185 $this->
options[
'thumbsize'] =
$user->getOption(
'thumbsize' );
1186 $this->
options[
'stubthreshold'] =
$user->getStubThreshold();
1201 foreach ( self::$lazyOptions
as $name => $callback ) {
1205 if ( $other->options[
$name] ===
null ) {
1206 $other->options[
$name] = call_user_func( $callback, $other,
$name );
1213 'enableLimitReport',
1218 if ( $o1 !== $o2 ) {
1224 $fields = array_keys( get_class_vars( __CLASS__ ) );
1225 $fields = array_diff( $fields, [
1232 foreach ( $fields
as $field ) {
1233 if ( !is_object( $this->$field ) && $this->$field !== $other->$field ) {
1247 $this->onAccessCallback = $callback;
1259 if ( $this->onAccessCallback ) {
1260 call_user_func( $this->onAccessCallback, $optionName );
1272 if ( self::$defaults ===
null ) {
1275 return array_keys( array_filter( self::$inCacheKey ) );
1286 } elseif (
$value ===
false ) {
1288 } elseif (
$value ===
null ) {
1291 return $value->getCode();
1292 } elseif ( is_array(
$value ) ) {
1293 return '[' . implode(
',', array_map( [ $this,
'optionToString' ],
$value ) ) .
']';
1317 foreach ( array_intersect( $forOptions,
$inCacheKey, array_keys( self::$lazyOptions ) )
as $k ) {
1318 if ( $this->
options[$k] ===
null ) {
1319 $this->
options[$k] = call_user_func( self::$lazyOptions[$k], $this, $k );
1332 foreach ( array_intersect(
$inCacheKey, $forOptions )
as $option ) {
1336 $values[] =
"$option=$v";
1340 $confstr = $values ? implode(
'!', $values ) :
'canonical';
1344 if ( !is_null(
$title ) ) {
1345 $confstr .=
$title->getPageLanguage()->getExtraHashOptions();
1348 MediaWikiServices::getInstance()->getContentLanguage()->getExtraHashOptions();
1353 if ( $this->mExtraKey !=
'' ) {
1359 Hooks::run(
'PageRenderingHash', [ &$confstr, $this->
getUser(), &$forOptions ] );
1362 $confstr = str_replace(
' ',
'_', $confstr );
1375 if ( empty( self::$inCacheKey[$option] ) ) {
1401 if ( $titleToCheck->equals(
$title ) ) {
1403 'page' =>
$title->getArticleID(),
1404 'user_text' =>
$user->getName(),
1405 'user' =>
$user->getId(),
1406 'parent_id' =>
$title->getLatestRevID(),
1411 return call_user_func( $oldCallback, $titleToCheck,
$parser );
1418 function ( $titleToCheck, &$exists )
use (
$title ) {
1419 if ( $titleToCheck->equals(
$title ) ) {
1425 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
1426 $linkCache->clearBadLink(
$title->getPrefixedDBkey() );
1427 return new ScopedCallback(
function ()
use (
$title, $key, $linkCache ) {
1429 unset(
$wgHooks[
'TitleExists'][$key] );
1430 $linkCache->clearLink(
$title );
static getDefaultOption( $opt)
Get a given default option value.
setMaxIncludeSize( $x)
Maximum size of template expansions, in bytes.
getMagicPMIDLinks()
Are magic PMID links enabled?
Set options of the Parser.
setOptionLegacy( $name, $value)
Legacy implementation.
getAllowExternalImagesFrom()
External images to allow.
return true to allow those checks to and false if checking is done & $user
getWrapOutputClass()
Class to use to wrap output from Parser::parse()
getExpensiveParserFunctionLimit()
Maximum number of calls per parse to expensive parser functions.
setTidy( $x)
Use tidy to cleanup output HTML?
getIsSectionPreview()
Parsing the page for a "preview" operation on a single section?
$wgMaxArticleSize
Maximum article size in kilobytes.
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
getRemoveComments()
Remove HTML comments.
setAllowUnsafeRawHtml( $x)
If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of...
disableContentConversion( $x=true)
Whether content conversion should be disabled.
if(!isset( $args[0])) $lang
initialiseFromUser( $user, $lang)
Get user options.
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...
$wgMaxTemplateDepth
Maximum recursion depth for templates within templates.
getIsPreview()
Parsing the page for a "preview" operation?
getDisableTitleConversion()
Whether title conversion should be disabled.
setAllowExternalImages( $x)
Allow all external images inline?
setTemplateCallback( $x)
Callback for template fetching; first argument to call_user_func().
setIsPreview( $x)
Parsing the page for a "preview" operation?
setTargetLanguage( $x)
Target language for the parse.
getInterfaceMessage()
Parsing an interface message?
setIsSectionPreview( $x)
Parsing the page for a "preview" operation on a single section?
getSpeculativeRevId()
A guess for {{REVISIONID}}, calculated using the callback provided via setSpeculativeRevIdCallback().
static newFromAnon()
Get a ParserOptions object for an anonymous user.
setEnableImageWhitelist( $x)
Use the on-wiki external image whitelist?
$wgDisableTitleConversion
Whether to enable language variant conversion for links.
setWrapOutputClass( $className)
CSS class to use to wrap output from Parser::parse()
setSpeculativeRevIdCallback( $x)
Callback to generate a guess for {{REVISIONID}}.
disableTitleConversion( $x=true)
Whether title conversion should be disabled.
static initDateFormat(ParserOptions $popt)
Lazy initializer for dateFormat.
getIsPrintable()
Parsing the printable version of the page?
setMaxGeneratedPPNodeCount( $x)
Maximum number of nodes generated by Preprocessor::preprocessToObj()
setCurrentRevisionCallback( $x)
Callback for current revision fetching; first argument to call_user_func().
static array $inCacheKey
Specify options that are included in the cache key.
setMaxTemplateDepth( $x)
Maximum recursion depth for templates within templates.
getMagicRFCLinks()
Are magic RFC links enabled?
getUserLangObj()
Get the user language used by the parser for this page and split the parser cache.
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
registerWatcher( $callback)
Registers a callback for tracking which ParserOptions which are used.
setupFakeRevision( $title, $content, $user)
Sets a hook to force that a page exists, and sets a current revision callback to return a revision wi...
getDateFormat()
Date format index.
const HAS_NEWCANONICAL_FROM_CONTEXT
Flag indicating that newCanonical() accepts an IContextSource or the string 'canonical',...
setOption( $name, $value)
Set an option, generically.
static initSpeculativeRevId(ParserOptions $popt)
Callback registered with ParserOptions::$lazyOptions, triggered by getSpeculativeRevId().
setNumberHeadings( $x)
Automatically number headings?
namespace and then decline to actually register it file or subcat img or subcat $title
static getCanonicalOverrides()
Get "canonical" non-default option values.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
getRedirectTarget()
Get the previously-set redirect target.
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
setUserLang( $x)
Set the user language used by the parser for this page and split the parser cache.
getAllowSpecialInclusion()
Allow inclusion of special pages?
$wgAllowExternalImagesFrom
If the above is false, you can specify an exception here.
getTidy()
Use tidy to cleanup output HTML?
getMaxIncludeSize()
Maximum size of template expansions, in bytes.
string null $mTimestamp
Timestamp used for {{CURRENTDAY}} etc.
$wgExpensiveParserFunctionLimit
Maximum number of calls per parse to expensive parser functions such as PAGESINCATEGORY.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
setThumbSize( $x)
Thumb size preferred by the user.
getEnableImageWhitelist()
Use the on-wiki external image whitelist?
$wgInterwikiMagic
Treat language links as magic connectors, not inline links.
setExternalLinkTarget( $x)
Target attribute for external links.
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
setDateFormat( $x)
Date format index.
getTargetLanguage()
Target language for the parse.
setAllowSpecialInclusion( $x)
Allow inclusion of special pages?
static getDefaults()
Get default option values.
getExternalLinkTarget()
Target attribute for external links.
callable null $onAccessCallback
Function to be called when an option is accessed.
$wgEnableMagicLinks
Enable the magic links feature of automatically turning ISBN xxx, PMID xxx, RFC xxx into links.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
getStubThreshold()
Thumb size preferred by the user.
$wgExternalLinkTarget
Set a default target for external links, e.g.
array $options
Current values for all options that are relevant for caching.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
getUserLang()
Same as getUserLangObj() but returns a string instead.
$wgDisableLangConversion
Whether to enable language variant conversion.
getPreSaveTransform()
Transform wiki markup when saving the page?
setStubThreshold( $x)
Thumb size preferred by the user.
getOption( $name)
Fetch an option, generically.
$mExtraKey
Appended to the options hash.
getAllowUnsafeRawHtml()
If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of...
Allows to change the fields on the form that will be generated $name
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message key
getDisableContentConversion()
Whether content conversion should be disabled.
optionToString( $value)
Convert an option to a string value.
optionUsed( $optionName)
Called when an option is accessed.
setTimestamp( $x)
Timestamp used for {{CURRENTDAY}} etc.
setCleanSignatures( $x)
Clean up signature texts?
getSpeculativeRevIdCallback()
Callback to generate a guess for {{REVISIONID}}.
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
getCurrentRevisionCallback()
Callback for current revision fetching; first argument to call_user_func().
$wgEnableParserLimitReporting
Whether to include the NewPP limit report as a HTML comment.
getTemplateCallback()
Callback for template fetching; first argument to call_user_func().
static newCanonical( $context=null, $userLang=null)
Creates a "canonical" ParserOptions object.
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
setRemoveComments( $x)
Remove HTML comments.
setInterwikiMagic( $x)
Specify whether to extract interlanguage links.
setRedirectTarget( $title)
Set the redirect target.
setExpensiveParserFunctionLimit( $x)
Maximum number of calls per parse to expensive parser functions.
getTimestamp()
Timestamp used for {{CURRENTDAY}} etc.
setMaxPPNodeCount( $x)
Maximum number of nodes touched by PPFrame::expand()
Interface for objects which can provide a MediaWiki context on request.
getCleanSignatures()
Clean up signature texts?
Title null $redirectTarget
If the page being parsed is a redirect, this should hold the redirect target.
setAllowExternalImagesFrom( $x)
External images to allow.
matches(ParserOptions $other)
Check if these options match that of another options set.
enableLimitReport( $x=true)
Enable limit report in an HTML comment on output.
Represents a title within MediaWiki.
__construct( $user=null, $lang=null)
getInterwikiMagic()
Whether to extract interlanguage links.
static callable[] $lazyOptions
Lazy-loaded options.
User $mUser
Stored user object.
setInterfaceMessage( $x)
Parsing an interface message?
static array null $defaults
Default values for all options that are relevant for caching.
$wgHooks['ArticleShow'][]
static allCacheVaryingOptions()
Return all option keys that vary the options hash.
$wgCleanSignatures
If true, removes (by substituting) templates in signatures.
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
getThumbSize()
Thumb size preferred by the user.
static isRealObject( $obj)
Returns a bool value whenever $obj is a stub object.
getMagicISBNLinks()
Are magic ISBN links enabled?
setIsPrintable( $x)
Parsing the printable version of the page?
getMaxPPNodeCount()
Maximum number of nodes touched by PPFrame::expand()
$wgRenderHashAppend
Append a configured value to the parser cache and the sitenotice key so that they can be kept separat...
$wgMaxGeneratedPPNodeCount
A complexity limit on template expansion: the maximum number of elements generated by Preprocessor::p...
setEditSection( $x)
Create "edit section" links?
static factory( $code)
Get a cached or new language object for a given language code.
getMaxGeneratedPPNodeCount()
Maximum number of nodes generated by Preprocessor::preprocessToObj()
getMaxPPExpandDepth()
Maximum recursion depth in PPFrame::expand()
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
getEnableLimitReport()
Enable limit report in an HTML comment on output.
getNumberHeadings()
Automatically number headings?
isSafeToCache()
Test whether these options are safe to cache.
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 MediaWikiServices
getMaxTemplateDepth()
Maximum recursion depth for templates within templates.
setPreSaveTransform( $x)
Transform wiki markup when saving the page?
getEditSection()
Create "edit section" links?
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function 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
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
$wgMaxPPNodeCount
A complexity limit on template expansion: the maximum number of nodes visited by PPFrame::expand()
Internationalisation code.
optionsHash( $forOptions, $title=null)
Generate a hash string with the values set on these ParserOptions for the keys given in the array.
getAllowExternalImages()
Allow all external images inline?
static newFromUser( $user)
Get a ParserOptions object from a given user.
$wgAllowExternalImages
Whether to allow inline image pointing to other websites.
$wgEnableImageWhitelist
If $wgAllowExternalImages is false, you can allow an on-wiki whitelist of regular expression fragment...
addExtraKey( $key)
Extra key that should be present in the parser cache key.
$wgAllowSpecialInclusion
Allow special page inclusions such as {{Special:Allpages}}.