MediaWiki REL1_33
|
This is a class for holding configuration settings, particularly for multi-wiki sites. More...
Public Member Functions | |
doReplace ( $from, $to, $in) | |
Type-safe string replace; won't do replacements on non-strings private? | |
extractAllGlobals ( $wiki, $suffix=null, $params=[], $wikiTags=[]) | |
Retrieves the values of all settings, and places them in their corresponding global variables. | |
extractGlobal ( $setting, $wiki, $suffix=null, $params=[], $wikiTags=[]) | |
Retrieves the value of a given setting, and places it in its corresponding global variable. | |
extractGlobalSetting ( $setting, $wiki, $params) | |
extractVar ( $setting, $wiki, $suffix, &$var, $params=[], $wikiTags=[]) | |
Retrieves the value of a given setting, and places it in a variable passed by reference. | |
get ( $settingName, $wiki, $suffix=null, $params=[], $wikiTags=[]) | |
Retrieves a configuration setting for a given wiki. | |
getAll ( $wiki, $suffix=null, $params=[], $wikiTags=[]) | |
Gets all settings for a wiki. | |
getBool ( $setting, $wiki, $suffix=null, $wikiTags=[]) | |
Retrieves a configuration setting for a given wiki, forced to a boolean. | |
getConfig ( $wiki, $settings) | |
Get the resolved (post-setup) configuration of a potentially foreign wiki. | |
& | getLocalDatabases () |
Retrieves an array of local databases. | |
loadFullData () | |
siteFromDB ( $wiki) | |
Work out the site and language name from a database name. | |
Static Public Member Functions | |
static | arrayMerge ( $array1) |
Merge multiple arrays together. | |
Public Attributes | |
string array | $fullLoadCallback = null |
Optional callback to load full configuration data. | |
$fullLoadDone = false | |
Whether or not all data has been loaded. | |
$localVHosts = [] | |
Array of domains that are local and can be handled by the same server. | |
$settings = [] | |
The whole array of settings. | |
string array | $siteParamsCallback = null |
A callback function that returns an array with the following keys (all optional): | |
$suffixes = [] | |
Array of suffixes, for self::siteFromDB() | |
$wikis = [] | |
Array of wikis, should be the same as $wgLocalDatabases. | |
Protected Member Functions | |
getSetting ( $settingName, $wiki, array $params) | |
Really retrieves a configuration setting for a given wiki. | |
getWikiParams ( $wiki) | |
Return specific settings for $wiki See the documentation of self::$siteParamsCallback for more in-depth documentation about this function. | |
mergeParams ( $wiki, $suffix, array $params, array $wikiTags) | |
Merge params between the ones passed to the function and the ones given by self::$siteParamsCallback for backward compatibility Values returned by self::getWikiParams() have the priority. | |
Protected Attributes | |
array | $cfgCache = [] |
Configuration cache for getConfig() | |
This is a class for holding configuration settings, particularly for multi-wiki sites.
A basic synopsis:
Consider a wikifarm having three sites: two production sites, one in English and one in German, and one testing site. You can assign them easy-to-remember identifiers - ISO 639 codes 'en' and 'de' for language wikis, and 'beta' for the testing wiki.
You would thus initialize the site configuration by specifying the wiki identifiers:
When configuring the MediaWiki global settings (the $wg variables), the identifiers will be available to specify settings on a per wiki basis.
With three wikis, that is easy to manage. But what about a farm with hundreds of wikis? Site configuration provides a special keyword named 'default' which is the value used when a wiki is not found. Hence the above code could be written:
Since settings can contain arrays, site configuration provides a way to merge an array with the default. This is very useful to avoid repeating settings again and again while still maintaining specific changes on a per wiki basis.
Finally, to load all configuration settings, extract them in global context:
Definition at line 124 of file SiteConfiguration.php.
|
static |
Merge multiple arrays together.
On encountering duplicate keys, merge the two, but ONLY if they're arrays. PHP's array_merge_recursive() merges ANY duplicate values into arrays, which is not fun
array | $array1 |
Definition at line 588 of file SiteConfiguration.php.
References $out, $value, and(), and arrayMerge().
Referenced by arrayMerge(), extractGlobalSetting(), getAll(), and getSetting().
SiteConfiguration::doReplace | ( | $from, | |
$to, | |||
$in ) |
Type-safe string replace; won't do replacements on non-strings private?
string | $from | |
string | $to | |
string | array | $in |
Definition at line 281 of file SiteConfiguration.php.
References and(), and doReplace().
Referenced by doReplace(), and getSetting().
SiteConfiguration::extractAllGlobals | ( | $wiki, | |
$suffix = null, | |||
$params = [], | |||
$wikiTags = [] ) |
Retrieves the values of all settings, and places them in their corresponding global variables.
string | $wiki | Wiki ID of the wiki in question. |
string | null | $suffix | The suffix of the wiki in question. |
array | $params | List of parameters. $.'key' is replaced by $value in all returned data. |
array | $wikiTags | The tags assigned to the wiki. |
Definition at line 406 of file SiteConfiguration.php.
References $params, extractGlobalSetting(), mergeParams(), and settings.
SiteConfiguration::extractGlobal | ( | $setting, | |
$wiki, | |||
$suffix = null, | |||
$params = [], | |||
$wikiTags = [] ) |
Retrieves the value of a given setting, and places it in its corresponding global variable.
string | $setting | ID of the setting name to retrieve |
string | $wiki | Wiki ID of the wiki in question. |
string | null | $suffix | The suffix of the wiki in question. |
array | $params | List of parameters. $.'key' is replaced by $value in all returned data. |
array | $wikiTags | The tags assigned to the wiki. |
Definition at line 371 of file SiteConfiguration.php.
References $params, extractGlobalSetting(), and mergeParams().
SiteConfiguration::extractGlobalSetting | ( | $setting, | |
$wiki, | |||
$params ) |
string | $setting | |
string | $wiki | |
array | $params |
Definition at line 383 of file SiteConfiguration.php.
References $GLOBALS, $params, $value, and(), arrayMerge(), and getSetting().
Referenced by extractAllGlobals(), and extractGlobal().
SiteConfiguration::extractVar | ( | $setting, | |
$wiki, | |||
$suffix, | |||
& | $var, | ||
$params = [], | |||
$wikiTags = [] ) |
Retrieves the value of a given setting, and places it in a variable passed by reference.
string | $setting | ID of the setting name to retrieve |
string | $wiki | Wiki ID of the wiki in question. |
string | $suffix | The suffix of the wiki in question. |
array | &$var | Reference The variable to insert the value into. |
array | $params | List of parameters. $.'key' is replaced by $value in all returned data. |
array | $wikiTags | The tags assigned to the wiki. |
Definition at line 354 of file SiteConfiguration.php.
SiteConfiguration::get | ( | $settingName, | |
$wiki, | |||
$suffix = null, | |||
$params = [], | |||
$wikiTags = [] ) |
Retrieves a configuration setting for a given wiki.
string | $settingName | ID of the setting name to retrieve |
string | $wiki | Wiki ID of the wiki in question. |
string | null | $suffix | The suffix of the wiki in question. |
array | $params | List of parameters. $.'key' is replaced by $value in all returned data. |
array | $wikiTags | The tags assigned to the wiki. |
Definition at line 188 of file SiteConfiguration.php.
References $params, getSetting(), and mergeParams().
SiteConfiguration::getAll | ( | $wiki, | |
$suffix = null, | |||
$params = [], | |||
$wikiTags = [] ) |
Gets all settings for a wiki.
string | $wiki | Wiki ID of the wiki in question. |
string | null | $suffix | The suffix of the wiki in question. |
array | $params | List of parameters. $.'key' is replaced by $value in all returned data. |
array | $wikiTags | The tags assigned to the wiki. |
Definition at line 302 of file SiteConfiguration.php.
References $GLOBALS, $params, $value, and(), arrayMerge(), getSetting(), mergeParams(), and settings.
SiteConfiguration::getBool | ( | $setting, | |
$wiki, | |||
$suffix = null, | |||
$wikiTags = [] ) |
Retrieves a configuration setting for a given wiki, forced to a boolean.
string | $setting | ID of the setting name to retrieve |
string | $wiki | Wiki ID of the wiki in question. |
string | null | $suffix | The suffix of the wiki in question. |
array | $wikiTags | The tags assigned to the wiki. |
Definition at line 332 of file SiteConfiguration.php.
References and().
SiteConfiguration::getConfig | ( | $wiki, | |
$settings ) |
Get the resolved (post-setup) configuration of a potentially foreign wiki.
For foreign wikis, this is expensive, and only works if maintenance scripts are setup to handle the –wiki parameter such as in wiki farms.
string | $wiki | |
array | string | $settings | A setting name or array of setting names |
MWException |
Definition at line 526 of file SiteConfiguration.php.
References $data, $GLOBALS, $IP, $name, $res, $settings, and(), array(), and unserialize().
& SiteConfiguration::getLocalDatabases | ( | ) |
Retrieves an array of local databases.
Definition at line 341 of file SiteConfiguration.php.
References $wikis.
|
protected |
Really retrieves a configuration setting for a given wiki.
string | $settingName | ID of the setting name to retrieve. |
string | $wiki | Wiki ID of the wiki in question. |
array | $params | Array of parameters. |
Definition at line 203 of file SiteConfiguration.php.
References $params, $value, and(), arrayMerge(), doReplace(), and settings.
Referenced by extractGlobalSetting(), get(), and getAll().
|
protected |
Return specific settings for $wiki See the documentation of self::$siteParamsCallback for more in-depth documentation about this function.
string | $wiki |
Definition at line 423 of file SiteConfiguration.php.
References $name, $ret, $siteParamsCallback, and and().
Referenced by mergeParams(), and siteFromDB().
SiteConfiguration::loadFullData | ( | ) |
Definition at line 608 of file SiteConfiguration.php.
References $fullLoadCallback.
Merge params between the ones passed to the function and the ones given by self::$siteParamsCallback for backward compatibility Values returned by self::getWikiParams() have the priority.
string | $wiki | Wiki ID of the wiki in question. |
string | $suffix | The suffix of the wiki in question. |
array | $params | List of parameters. $.'key' is replaced by $value in all returned data. |
array | $wikiTags | The tags assigned to the wiki. |
Definition at line 462 of file SiteConfiguration.php.
References $params, $ret, and(), and getWikiParams().
Referenced by extractAllGlobals(), extractGlobal(), get(), and getAll().
SiteConfiguration::siteFromDB | ( | $wiki | ) |
Work out the site and language name from a database name.
string | $wiki | Wiki ID |
Definition at line 490 of file SiteConfiguration.php.
References $lang, and(), and getWikiParams().
|
protected |
Configuration cache for getConfig()
Definition at line 177 of file SiteConfiguration.php.
Optional callback to load full configuration data.
Definition at line 152 of file SiteConfiguration.php.
Referenced by loadFullData().
SiteConfiguration::$fullLoadDone = false |
Whether or not all data has been loaded.
Definition at line 155 of file SiteConfiguration.php.
SiteConfiguration::$localVHosts = [] |
Array of domains that are local and can be handled by the same server.
Definition at line 146 of file SiteConfiguration.php.
SiteConfiguration::$settings = [] |
The whole array of settings.
Definition at line 139 of file SiteConfiguration.php.
Referenced by getConfig().
A callback function that returns an array with the following keys (all optional):
Definition at line 171 of file SiteConfiguration.php.
Referenced by getWikiParams().
SiteConfiguration::$suffixes = [] |
Array of suffixes, for self::siteFromDB()
Definition at line 129 of file SiteConfiguration.php.
SiteConfiguration::$wikis = [] |
Array of wikis, should be the same as $wgLocalDatabases.
Definition at line 134 of file SiteConfiguration.php.
Referenced by getLocalDatabases().