MediaWiki
master
|
Settings loaded from a local file path. More...
Public Member Functions | |
__construct (string $path, SettingsFormat $format=null) | |
Constructs a new FileSource for the given path and possibly a custom format to decode the contents. More... | |
__toString () | |
Returns this file source as a string. More... | |
allowsStaleLoad () | |
Disallow stale results from file sources in the case of load failure as failing to read from disk would be quite catastrophic and worthy of propagation. More... | |
getExpiryTtl () | |
The cache expiry TTL (in seconds) for this file source. More... | |
getExpiryWeight () | |
Coefficient used in determining early expiration of cached settings to avoid stampedes. More... | |
getHashKey () | |
Returns a hash key computed from the file's inode, size, and last modified timestamp. More... | |
load () | |
Loads contents from the file and decodes them using the first format to claim support for the file's extension. More... | |
locateInclude (string $location) | |
This method defines how a relative reference to the location of another settings source is interpreted. More... | |
Private Member Functions | |
readAndDecode (SettingsFormat $format) | |
Reads and decodes the file contents using the given format. More... | |
Private Attributes | |
SettingsFormat | $format |
Format to use for reading the file, if given. More... | |
string | $path |
Path to local file. More... | |
const | BUILT_IN_FORMATS |
const | EXPIRY_TTL = 60 * 60 * 24 |
Cache expiry TTL for file sources (24 hours). More... | |
const | EXPIRY_WEIGHT = 1.0 |
Early expiry weight. More... | |
MediaWiki\Settings\Source\FileSource::__construct | ( | string | $path, |
SettingsFormat | $format = null |
||
) |
Constructs a new FileSource for the given path and possibly a custom format to decode the contents.
If no format is given, the built-in formats will be tried and the first one that supports the file extension will be used.
Built-in formats:
<?php $source = new FileSource( 'my/settings.json' ); $source->load();
While a specialized caller may want to pass a specialized format
<?php $source = new FileSource( 'my/settings.toml', new TomlFormat() ); $source->load();
string | $path | |
SettingsFormat | null | $format |
Definition at line 87 of file FileSource.php.
References MediaWiki\Settings\Source\FileSource\$format, and MediaWiki\Settings\Source\FileSource\$path.
MediaWiki\Settings\Source\FileSource::__toString | ( | ) |
MediaWiki\Settings\Source\FileSource::allowsStaleLoad | ( | ) |
Disallow stale results from file sources in the case of load failure as failing to read from disk would be quite catastrophic and worthy of propagation.
Implements MediaWiki\Settings\Cache\CacheableSource.
Definition at line 99 of file FileSource.php.
MediaWiki\Settings\Source\FileSource::getExpiryTtl | ( | ) |
The cache expiry TTL (in seconds) for this file source.
Implements MediaWiki\Settings\Cache\CacheableSource.
Definition at line 138 of file FileSource.php.
MediaWiki\Settings\Source\FileSource::getExpiryWeight | ( | ) |
Coefficient used in determining early expiration of cached settings to avoid stampedes.
Implements MediaWiki\Settings\Cache\CacheableSource.
Definition at line 148 of file FileSource.php.
MediaWiki\Settings\Source\FileSource::getHashKey | ( | ) |
Returns a hash key computed from the file's inode, size, and last modified timestamp.
Implements MediaWiki\Settings\Cache\CacheableSource.
Definition at line 158 of file FileSource.php.
MediaWiki\Settings\Source\FileSource::load | ( | ) |
Loads contents from the file and decodes them using the first format to claim support for the file's extension.
SettingsBuilderException |
Implements MediaWiki\Settings\Source\SettingsSource.
Definition at line 110 of file FileSource.php.
MediaWiki\Settings\Source\FileSource::locateInclude | ( | string | $location | ) |
This method defines how a relative reference to the location of another settings source is interpreted.
It tries to make $location absolute by interpreting it as relative to the location of the SettingsSource it originates from.
Implementation are "best effort". If a location cannot be made absolute, it may be returned as-is. Implementations are also free to throw a SettingsBuilderException to indicate that the given include location is not supported in this context.
string | $location |
SettingsBuilderException | if the given location cannot be used as an include by the current source. |
Implements MediaWiki\Settings\Source\SettingsIncludeLocator.
Definition at line 225 of file FileSource.php.
|
private |
Reads and decodes the file contents using the given format.
SettingsFormat | $format |
SettingsBuilderException |
Definition at line 188 of file FileSource.php.
|
private |
Format to use for reading the file, if given.
Definition at line 50 of file FileSource.php.
Referenced by MediaWiki\Settings\Source\FileSource\__construct().
|
private |
Path to local file.
Definition at line 56 of file FileSource.php.
Referenced by MediaWiki\Settings\Source\FileSource\__construct().
|
private |
Definition at line 19 of file FileSource.php.
|
private |
Cache expiry TTL for file sources (24 hours).
Definition at line 30 of file FileSource.php.
|
private |
Early expiry weight.
This value influences the margin by which processes are selected to expire cached local-file settings early to avoid cache stampedes. Changes to this value are not likely to be necessary as time spent loading from local files should not have much variation and should already be well served by the default early expiry calculation.
Definition at line 43 of file FileSource.php.