186 public function get( $settingName, $wiki, $suffix =
null,
$params = [],
203 if ( array_key_exists( $settingName, $this->
settings ) ) {
204 $thisSetting =& $this->
settings[$settingName];
207 if ( array_key_exists( $wiki, $thisSetting ) ) {
210 } elseif ( array_key_exists(
"+$wiki", $thisSetting ) && is_array( $thisSetting[
"+$wiki"] ) ) {
211 $retval = $thisSetting[
"+$wiki"];
215 foreach (
$params[
'tags'] as $tag ) {
216 if ( array_key_exists( $tag, $thisSetting ) ) {
217 if ( is_array(
$retval ) && is_array( $thisSetting[$tag] ) ) {
223 } elseif ( array_key_exists(
"+$tag", $thisSetting ) && is_array( $thisSetting[
"+$tag"] ) ) {
232 if ( !is_null( $suffix ) ) {
233 if ( array_key_exists( $suffix, $thisSetting ) ) {
234 if ( is_array(
$retval ) && is_array( $thisSetting[$suffix] ) ) {
237 $retval = $thisSetting[$suffix];
240 } elseif ( array_key_exists(
"+$suffix", $thisSetting )
241 && is_array( $thisSetting[
"+$suffix"] )
251 if ( array_key_exists(
'default', $thisSetting ) ) {
252 if ( is_array(
$retval ) && is_array( $thisSetting[
'default'] ) ) {
255 $retval = $thisSetting[
'default'];
280 if ( is_string( $in ) ) {
281 return str_replace( $from, $to, $in );
282 } elseif ( is_array( $in ) ) {
283 foreach ( $in as $key => $val ) {
284 $in[$key] = $this->
doReplace( $from, $to, $val );
300 public function getAll( $wiki, $suffix =
null,
$params = [], $wikiTags = [] ) {
303 foreach ( $this->
settings as $varname => $stuff ) {
306 if ( substr( $varname, 0, 1 ) ==
'+' ) {
308 $var = substr( $varname, 1 );
312 if ( $append && is_array(
$value ) && is_array(
$GLOBALS[$var] ) ) {
315 if ( !is_null(
$value ) ) {
316 $localSettings[$var] =
$value;
319 return $localSettings;
330 public function getBool( $setting, $wiki, $suffix =
null, $wikiTags = [] ) {
331 return (
bool)$this->
get( $setting, $wiki, $suffix, [], $wikiTags );
355 $value = $this->
get( $setting, $wiki, $suffix,
$params, $wikiTags );
356 if ( !is_null(
$value ) ) {
383 if ( !is_null(
$value ) ) {
384 if ( substr( $setting, 0, 1 ) ==
'+' && is_array(
$value ) ) {
385 $setting = substr( $setting, 1 );
386 if ( is_array(
$GLOBALS[$setting] ) ) {
408 foreach ( $this->
settings as $varName => $setting ) {
429 if ( !is_callable( $this->siteParamsCallback ) ) {
433 $ret = call_user_func_array( $this->siteParamsCallback, [ $this, $wiki ] );
434 # Validate the returned value
435 if ( !is_array(
$ret ) ) {
439 foreach ( $default as $name => $def ) {
440 if ( !isset(
$ret[$name] ) || ( is_array( $default[$name] ) && !is_array(
$ret[$name] ) ) ) {
463 if ( is_null(
$ret[
'suffix'] ) ) {
464 $ret[
'suffix'] = $suffix;
467 $ret[
'tags'] = array_unique( array_merge(
$ret[
'tags'], $wikiTags ) );
472 if ( !isset(
$ret[
'params'][
'lang'] ) && !is_null(
$ret[
'lang'] ) ) {
473 $ret[
'params'][
'lang'] =
$ret[
'lang'];
475 if ( !isset(
$ret[
'params'][
'site'] ) && !is_null(
$ret[
'suffix'] ) ) {
476 $ret[
'params'][
'site'] =
$ret[
'suffix'];
491 if ( !is_null( $def[
'suffix'] ) && !is_null( $def[
'lang'] ) ) {
492 return [ $def[
'suffix'], $def[
'lang'] ];
497 foreach ( $this->suffixes as $altSite => $suffix ) {
498 if ( $suffix ===
'' ) {
502 } elseif ( substr( $db, -strlen( $suffix ) ) == $suffix ) {
503 $site = is_numeric( $altSite ) ? $suffix : $altSite;
504 $lang = substr( $db, 0, strlen( $db ) - strlen( $suffix ) );
509 return [ $site,
$lang ];
531 if ( !preg_match(
'/^wg[A-Z]/', $name ) ) {
532 throw new MWException(
"Variable '$name' does start with 'wg'." );
533 } elseif ( !isset(
$GLOBALS[$name] ) ) {
534 throw new MWException(
"Variable '$name' is not set." );
539 if ( isset( $this->cfgCache[$wiki] ) ) {
540 $res = array_intersect_key( $this->cfgCache[$wiki], array_flip(
$settings ) );
542 return $multi ?
$res : current(
$res );
544 } elseif ( !in_array( $wiki, $this->wikis ) ) {
547 $this->cfgCache[$wiki] = [];
551 "$IP/maintenance/getConfiguration.php",
559 $data = trim(
wfShellExec( $cmd, $retVal, [], [
'memory' => 0 ] ) );
560 if ( $retVal != 0 || !strlen( $data ) ) {
561 throw new MWException(
"Failed to run getConfiguration.php." );
564 if ( !is_array(
$res ) ) {
565 throw new MWException(
"Failed to unserialize configuration array." );
567 $this->cfgCache[$wiki] = $this->cfgCache[$wiki] +
$res;
570 return $multi ?
$res : current(
$res );
585 $argsCount = func_num_args();
586 for ( $i = 1; $i < $argsCount; $i++ ) {
587 foreach ( func_get_arg( $i ) as $key =>
$value ) {
588 if ( isset(
$out[$key] ) && is_array(
$out[$key] ) && is_array(
$value ) ) {
590 } elseif ( !isset(
$out[$key] ) || !
$out[$key] && !is_numeric( $key ) ) {
594 } elseif ( is_numeric( $key ) ) {
604 if ( $this->fullLoadCallback && !$this->fullLoadDone ) {
605 call_user_func( $this->fullLoadCallback, $this );
606 $this->fullLoadDone =
true;
unserialize( $serialized)
$GLOBALS['wgAutoloadClasses']['LocalisationUpdate']
wfShellExec( $cmd, &$retval=null, $environ=[], $limits=[], $options=[])
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...
wfShellWikiCmd( $script, array $parameters=[], array $options=[])
Generate a shell-escaped command line string to run a MediaWiki cli script.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
This is a class for holding configuration settings, particularly for multi-wiki sites.
getConfig( $wiki, $settings)
Get the resolved (post-setup) configuration of a potentially foreign wiki.
$localVHosts
Array of domains that are local and can be handled by the same server.
extractAllGlobals( $wiki, $suffix=null, $params=[], $wikiTags=[])
Retrieves the values of all settings, and places them in their corresponding global variables.
$wikis
Array of wikis, should be the same as $wgLocalDatabases.
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 ...
static arrayMerge( $array1)
Merge multiple arrays together.
array $cfgCache
Configuration cache for getConfig()
string array $fullLoadCallback
Optional callback to load full configuration data.
extractGlobal( $setting, $wiki, $suffix=null, $params=[], $wikiTags=[])
Retrieves the value of a given setting, and places it in its corresponding global variable.
string array $siteParamsCallback
A callback function that returns an array with the following keys (all optional):
extractGlobalSetting( $setting, $wiki, $params)
getAll( $wiki, $suffix=null, $params=[], $wikiTags=[])
Gets all settings for a wiki.
extractVar( $setting, $wiki, $suffix, &$var, $params=[], $wikiTags=[])
Retrieves the value of a given setting, and places it in a variable passed by reference.
getWikiParams( $wiki)
Return specific settings for $wiki See the documentation of self::$siteParamsCallback for more in-dep...
siteFromDB( $db)
Work out the site and language name from a database name.
getBool( $setting, $wiki, $suffix=null, $wikiTags=[])
Retrieves a configuration setting for a given wiki, forced to a boolean.
$settings
The whole array of settings.
& getLocalDatabases()
Retrieves an array of local databases.
$fullLoadDone
Whether or not all data has been loaded.
$suffixes
Array of suffixes, for self::siteFromDB()
doReplace( $from, $to, $in)
Type-safe string replace; won't do replacements on non-strings private?
the array() calling protocol came about after MediaWiki 1.4rc1.
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 incomplete not yet checked for validity & $retval
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
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
Allows to change the fields on the form that will be generated $name
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
if(!isset( $args[0])) $lang