MediaWiki
master
|
Builder class for constructing a Config object from a set of sources during bootstrap. More...
Public Member Functions | |
__construct (string $baseDir, ExtensionRegistry $extensionRegistry, ConfigBuilder $configSink, PhpIniSink $phpIniSink, BagOStuff $cache=null) | |
apply () | |
Apply any settings loaded so far to the runtime environment. More... | |
assumeDirtyConfig () | |
Notify SettingsBuilder that it can no longer assume that is has full knowledge of all configuration variables that have been set. More... | |
detectDeprecatedConfig () | |
Detect usage of deprecated settings. More... | |
detectObsoleteConfig () | |
Detect usage of obsolete settings. More... | |
enterReadOnlyStage () | |
Sets the SettingsBuilder read-only. More... | |
enterRegistrationStage () | |
Prevents additional settings from being loaded, but still allows manipulation of config values. More... | |
fileExists (string $path) | |
Checks whether the given file exists relative to the settings builder's base directory. More... | |
getConfig () | |
Returns the config loaded so far. More... | |
getConfigBuilder () | |
getConfigSchema () | |
Return the configuration schema. More... | |
getDefaultConfig () | |
Return a Config object with default for all settings from all schemas loaded so far. More... | |
getDefinedConfigKeys () | |
Returns the names of all defined configuration variables. More... | |
getWarnings () | |
Returns any warnings logged by calling warning(). More... | |
load (SettingsSource $source) | |
Load settings from a SettingsSource. More... | |
loadArray (array $newSettings) | |
Load settings from an array. More... | |
loadFile (string $path) | |
Load settings from a file. More... | |
overrideConfigValue (string $key, $value) | |
Override the value of a config variable. More... | |
overrideConfigValues (array $values) | |
Override the value of multiple config variables. More... | |
putConfigValue (string $key, $value) | |
Puts a value into a config variable. More... | |
putConfigValues (array $values) | |
Sets the value of multiple config variables. More... | |
registerHookHandler (string $hook, $handler) | |
Register a hook handler. More... | |
registerHookHandlers (array $handlers) | |
Register hook handlers. More... | |
validate () | |
Assert that the config loaded so far conforms the schema loaded so far. More... | |
warning (string $msg) | |
Log a settings related warning, such as a deprecated config variable. More... | |
Static Public Member Functions | |
static | getInstance () |
Accessor for the global SettingsBuilder instance. More... | |
Builder class for constructing a Config object from a set of sources during bootstrap.
The SettingsBuilder is used in Setup.php to load and combine settings files and eventually produce the Config object that will be used to configure MediaWiki.
The SettingsBuilder object keeps track of "stages" of initialization that correspond to sections of Setup.php:
The initial stage is "loading". In this stage, SettingsSources are added to the SettingsBuilder using the load* methods. This sets up the config schema and applies custom configuration values.
Once all settings sources have been loaded, the SettingsBuilder is moved to the "registration" stage by calling enterRegistrationStage(). In this stage, config values may still be altered, but no settings sources may be loaded. During the "registration" stage, dynamic defaults are applied, extension registration callbacks are executed, and maintenance scripts have an opportunity to manipulate settings.
Finally, the SettingsBuilder is moved to the "operation" stage by calling enterOperationStage(). This renders the SettingsBuilder read only: config values may no longer be changed. At this point, it becomes safe to use the Config object returned by getConfig() to initialize the service container.
Definition at line 54 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::__construct | ( | string | $baseDir, |
ExtensionRegistry | $extensionRegistry, | ||
ConfigBuilder | $configSink, | ||
PhpIniSink | $phpIniSink, | ||
BagOStuff | $cache = null |
||
) |
string | $baseDir | |
ExtensionRegistry | $extensionRegistry | |
ConfigBuilder | $configSink | |
PhpIniSink | $phpIniSink | |
BagOStuff | null | $cache | BagOStuff used to cache settings loaded from each source. The caller should beware that secrets contained in any source passed to load or loadFile will be cached as well. |
Definition at line 173 of file SettingsBuilder.php.
References MediaWiki\MainConfigNames\ExtensionDirectory, and MediaWiki\MainConfigNames\StyleDirectory.
MediaWiki\Settings\SettingsBuilder::apply | ( | ) |
Apply any settings loaded so far to the runtime environment.
SettingsBuilderException |
Definition at line 405 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::assumeDirtyConfig | ( | ) |
Notify SettingsBuilder that it can no longer assume that is has full knowledge of all configuration variables that have been set.
This would be the case when other code (such as LocalSettings.php) is manipulating global variables which represent config values.
This is used for optimization: up until this method is called, default values can be set directly for any config values that have not been set yet. This avoids the need to run merge logic for all default values during initialization.
Definition at line 502 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::detectDeprecatedConfig | ( | ) |
Detect usage of deprecated settings.
A setting is counted as used if it has a value other than the default. Note that deprecated settings are expected to be supported. Settings that have become non-functional should be marked as obsolete instead.
Definition at line 311 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::detectObsoleteConfig | ( | ) |
Detect usage of obsolete settings.
A setting is counted as used if it is defined in any way. Note that obsolete settings are non-functional, while deprecated settings are still supported.
Definition at line 345 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::enterReadOnlyStage | ( | ) |
Sets the SettingsBuilder read-only.
Call this before using the configuration returned by getConfig() to construct services objects or initialize the service container.
Definition at line 777 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::enterRegistrationStage | ( | ) |
Prevents additional settings from being loaded, but still allows manipulation of config values.
Call this before applying dynamic defaults and executing extension registration callbacks.
Definition at line 789 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::fileExists | ( | string | $path | ) |
Checks whether the given file exists relative to the settings builder's base directory.
string | $path |
Definition at line 256 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::getConfig | ( | ) |
Returns the config loaded so far.
Implicitly triggers apply() when needed.
Definition at line 734 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::getConfigBuilder | ( | ) |
Definition at line 798 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::getConfigSchema | ( | ) |
Return the configuration schema.
Definition at line 381 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::getDefaultConfig | ( | ) |
Return a Config object with default for all settings from all schemas loaded so far.
If the schema for a setting doesn't specify a default, null is assumed.
Definition at line 366 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::getDefinedConfigKeys | ( | ) |
Returns the names of all defined configuration variables.
Definition at line 391 of file SettingsBuilder.php.
|
static |
Accessor for the global SettingsBuilder instance.
Definition at line 143 of file SettingsBuilder.php.
References ExtensionRegistry\getInstance().
MediaWiki\Settings\SettingsBuilder::getWarnings | ( | ) |
Returns any warnings logged by calling warning().
Definition at line 825 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::load | ( | SettingsSource | $source | ) |
Load settings from a SettingsSource.
Only allowed during the "loading" stage.
SettingsSource | $source |
Definition at line 201 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::loadArray | ( | array | $newSettings | ) |
Load settings from an array.
array | $newSettings |
Definition at line 217 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::loadFile | ( | string | $path | ) |
Load settings from a file.
string | $path |
Definition at line 245 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::overrideConfigValue | ( | string | $key, |
$value | |||
) |
Override the value of a config variable.
This ignores any merge strategies and discards any previous value. This is a shorthand for overrideConfigValues( [ $key => $value ] ).
string | $key | the name of the config setting |
mixed | $value | The value to set |
Definition at line 675 of file SettingsBuilder.php.
Referenced by MediaWiki\Maintenance\MaintenanceRunner\emulateConfig().
MediaWiki\Settings\SettingsBuilder::overrideConfigValues | ( | array | $values | ) |
Override the value of multiple config variables.
This ignores any merge strategies and discards any previous value. This is a shorthand for loadArray( [ 'config-overrides' => $values ] ).
array | $values | An associative array mapping names to values. |
Definition at line 690 of file SettingsBuilder.php.
Referenced by Installer\overrideConfig().
MediaWiki\Settings\SettingsBuilder::putConfigValue | ( | string | $key, |
$value | |||
) |
Puts a value into a config variable.
Depending on the variable's specification, the new value may be merged with the previous value, or may replace it. This is a shorthand for putConfigValues( [ $key => $value ] ).
string | $key | the name of the config setting |
mixed | $value | The value to set |
Definition at line 643 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::putConfigValues | ( | array | $values | ) |
Sets the value of multiple config variables.
Depending on the variables' specification, the new values may be merged with the previous values, or they may replace them. This is a shorthand for loadArray( [ 'config' => $values ] ).
array | $values | An associative array mapping names to values. |
Definition at line 659 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::registerHookHandler | ( | string | $hook, |
$handler | |||
) |
Register a hook handler.
string | $hook | |
mixed | $handler |
Definition at line 720 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::registerHookHandlers | ( | array | $handlers | ) |
Register hook handlers.
array<string,mixed> | $handlers An associative array using the same structure as the Hooks config setting: Each value is a list of handler callbacks for the hook. |
Definition at line 704 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::validate | ( | ) |
Assert that the config loaded so far conforms the schema loaded so far.
Definition at line 293 of file SettingsBuilder.php.
MediaWiki\Settings\SettingsBuilder::warning | ( | string | $msg | ) |
Log a settings related warning, such as a deprecated config variable.
This can be used during bootstrapping, when the regular logger is not yet available. The warnings will be passed to a regular logger after bootstrapping is complete. In addition, the updater will fail if it finds any warnings. This allows us to warn about deprecated settings, and make sure they are replaced before the update proceeds.
string | $msg |
Definition at line 814 of file SettingsBuilder.php.