Go to the documentation of this file.
188 public function get( $settingName, $wiki, $suffix =
null,
$params = [],
205 if ( array_key_exists( $settingName, $this->
settings ) ) {
206 $thisSetting =& $this->
settings[$settingName];
209 if ( array_key_exists( $wiki, $thisSetting ) ) {
212 } elseif ( array_key_exists(
"+$wiki", $thisSetting ) && is_array( $thisSetting[
"+$wiki"] ) ) {
213 $retval = $thisSetting[
"+$wiki"];
218 if ( array_key_exists( $tag, $thisSetting ) ) {
219 if ( is_array(
$retval ) && is_array( $thisSetting[$tag] ) ) {
225 } elseif ( array_key_exists(
"+$tag", $thisSetting ) && is_array( $thisSetting[
"+$tag"] ) ) {
234 if ( !is_null( $suffix ) ) {
235 if ( array_key_exists( $suffix, $thisSetting ) ) {
236 if ( is_array(
$retval ) && is_array( $thisSetting[$suffix] ) ) {
239 $retval = $thisSetting[$suffix];
242 } elseif ( array_key_exists(
"+$suffix", $thisSetting )
243 && is_array( $thisSetting[
"+$suffix"] )
253 if ( array_key_exists(
'default', $thisSetting ) ) {
254 if ( is_array(
$retval ) && is_array( $thisSetting[
'default'] ) ) {
257 $retval = $thisSetting[
'default'];
282 if ( is_string( $in ) ) {
283 return str_replace( $from, $to, $in );
284 } elseif ( is_array( $in ) ) {
285 foreach ( $in
as $key => $val ) {
286 $in[$key] = $this->
doReplace( $from, $to, $val );
302 public function getAll( $wiki, $suffix =
null,
$params = [], $wikiTags = [] ) {
305 foreach ( $this->
settings as $varname => $stuff ) {
308 if ( substr( $varname, 0, 1 ) ==
'+' ) {
310 $var = substr( $varname, 1 );
314 if ( $append && is_array(
$value ) && is_array(
$GLOBALS[$var] ) ) {
317 if ( !is_null(
$value ) ) {
318 $localSettings[$var] =
$value;
321 return $localSettings;
332 public function getBool( $setting, $wiki, $suffix =
null, $wikiTags = [] ) {
333 return (
bool)$this->
get( $setting, $wiki, $suffix, [], $wikiTags );
357 $value = $this->
get( $setting, $wiki, $suffix,
$params, $wikiTags );
358 if ( !is_null(
$value ) ) {
385 if ( !is_null(
$value ) ) {
386 if ( substr( $setting, 0, 1 ) ==
'+' && is_array(
$value ) ) {
387 $setting = substr( $setting, 1 );
388 if ( is_array(
$GLOBALS[$setting] ) ) {
410 foreach ( $this->
settings as $varName => $setting ) {
431 if ( !is_callable( $this->siteParamsCallback ) ) {
436 # Validate the returned value
437 if ( !is_array(
$ret ) ) {
441 foreach ( $default
as $name => $def ) {
465 if ( is_null(
$ret[
'suffix'] ) ) {
466 $ret[
'suffix'] = $suffix;
469 $ret[
'tags'] = array_unique( array_merge(
$ret[
'tags'], $wikiTags ) );
474 if ( !isset(
$ret[
'params'][
'lang'] ) && !is_null(
$ret[
'lang'] ) ) {
475 $ret[
'params'][
'lang'] =
$ret[
'lang'];
477 if ( !isset(
$ret[
'params'][
'site'] ) && !is_null(
$ret[
'suffix'] ) ) {
478 $ret[
'params'][
'site'] =
$ret[
'suffix'];
493 if ( !is_null( $def[
'suffix'] ) && !is_null( $def[
'lang'] ) ) {
494 return [ $def[
'suffix'], $def[
'lang'] ];
499 foreach ( $this->suffixes
as $altSite => $suffix ) {
500 if ( $suffix ===
'' ) {
504 } elseif ( substr( $db, -strlen( $suffix ) ) == $suffix ) {
505 $site = is_numeric( $altSite ) ? $suffix : $altSite;
506 $lang = substr( $db, 0, strlen( $db ) - strlen( $suffix ) );
511 return [ $site,
$lang ];
533 if ( !preg_match(
'/^wg[A-Z]/',
$name ) ) {
534 throw new MWException(
"Variable '$name' does start with 'wg'." );
536 throw new MWException(
"Variable '$name' is not set." );
541 if ( isset( $this->cfgCache[$wiki] ) ) {
542 $res = array_intersect_key( $this->cfgCache[$wiki], array_flip(
$settings ) );
544 return $multi ?
$res : current(
$res );
546 } elseif ( !in_array( $wiki, $this->wikis ) ) {
549 $this->cfgCache[$wiki] = [];
551 $result = Shell::makeScriptCommand(
552 "$IP/maintenance/getConfiguration.php",
560 ->limits( [
'memory' => 0,
'filesize' => 0 ] )
563 $data = trim(
$result->getStdout() );
564 if (
$result->getExitCode() != 0 || !strlen( $data ) ) {
565 throw new MWException(
"Failed to run getConfiguration.php: {$result->getStdout()}" );
568 if ( !is_array(
$res ) ) {
569 throw new MWException(
"Failed to unserialize configuration array." );
571 $this->cfgCache[$wiki] = $this->cfgCache[$wiki] +
$res;
574 return $multi ?
$res : current(
$res );
589 $argsCount = func_num_args();
590 for ( $i = 1; $i < $argsCount; $i++ ) {
591 foreach ( func_get_arg( $i )
as $key =>
$value ) {
592 if ( isset(
$out[$key] ) && is_array(
$out[$key] ) && is_array(
$value ) ) {
594 } elseif ( !isset(
$out[$key] ) || !
$out[$key] && !is_numeric( $key ) ) {
598 } elseif ( is_numeric( $key ) ) {
608 if ( $this->fullLoadCallback && !$this->fullLoadDone ) {
610 $this->fullLoadDone =
true;
extractVar( $setting, $wiki, $suffix, &$var, $params=[], $wikiTags=[])
Retrieves the value of a given setting, and places it in a variable passed by reference.
$fullLoadDone
Whether or not all data has been loaded.
This is a class for holding configuration settings, particularly for multi-wiki sites.
if(!isset( $args[0])) $lang
getConfig( $wiki, $settings)
Get the resolved (post-setup) configuration of a potentially foreign wiki.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED since 1.16! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
extractAllGlobals( $wiki, $suffix=null, $params=[], $wikiTags=[])
Retrieves the values of all settings, and places them in their corresponding global variables.
doReplace( $from, $to, $in)
Type-safe string replace; won't do replacements on non-strings private?
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
getBool( $setting, $wiki, $suffix=null, $wikiTags=[])
Retrieves a configuration setting for a given wiki, forced to a boolean.
siteFromDB( $db)
Work out the site and language name from a database name.
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
array $cfgCache
Configuration cache for getConfig()
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration settings
$localVHosts
Array of domains that are local and can be handled by the same server.
string array $siteParamsCallback
A callback function that returns an array with the following keys (all optional):
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))
Allows to change the fields on the form that will be generated $name
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
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 account incomplete not yet checked for validity & $retval
getAll( $wiki, $suffix=null, $params=[], $wikiTags=[])
Gets all settings for a wiki.
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
static arrayMerge( $array1)
Merge multiple arrays together.
& getLocalDatabases()
Retrieves an array of local databases.
unserialize( $serialized)
$wikis
Array of wikis, should be the same as $wgLocalDatabases.
string array $fullLoadCallback
Optional callback to load full configuration data.
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
$settings
The whole array of settings.
extractGlobal( $setting, $wiki, $suffix=null, $params=[], $wikiTags=[])
Retrieves the value of a given setting, and places it in its corresponding global variable.
getSetting( $settingName, $wiki, array $params)
Really retrieves a configuration setting for a given wiki.
mergeParams( $wiki, $suffix, array $params, array $wikiTags)
Merge params between the ones passed to the function and the ones given by self::$siteParamsCallback ...
extractGlobalSetting( $setting, $wiki, $params)
$suffixes
Array of suffixes, for self::siteFromDB()
getWikiParams( $wiki)
Return specific settings for $wiki See the documentation of self::$siteParamsCallback for more in-dep...
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out