aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Settings/Source/ArraySource.php
Commit message (Collapse)AuthorAgeFilesLines
* Use type declaration for class properties holding type hinted argumentsUmherirrender2024-09-111-1/+1
| | | | | | | Provided arguments already have type declaration on the construtor and it is safe to use the same type on the class property Change-Id: Ia8bbdc4dee59dfb487582dd514486ec8542951be
* Add "implements Stringable" to every class with "function __toString()"Bartosz DziewoƄski2024-06-131-1/+3
| | | | | | | | | | | | | In PHP 8, but not in PHP 7.4, every class with a __toString() function implicitly implements the Stringable interface. Therefore, the behavior of checks like "instanceof Stringable" differs between these PHP versions when such classes are involved. Make every such class implement the interface so that the behavior will be consistent. The PHP 7.4 fallback for the Stringable interface is provided by symfony/polyfill-php80. Change-Id: I3f0330c2555c7d3bf99b654ed3c0b0303e257ea1
* Cache loading of SettingsBuilder sourcesDan Duvall2021-11-291-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `SettingsBuilder` now accepts a PSR-16 cache interface with which to store and query settings before attempting to load from each source. By default, no cache is used, but any object that implements the `Psr\SimpleCache\CacheInterface` may be provided to the constructor. An explicit dependency on "psr/simple-cache" has been added to `composer.json`. Note that this dependency already existed in vendor albeit it as a transitive one. An APCu based `SharedMemoryCache` adapter is provided as a canonical PSR-16 compliant interface for production use. Sources are now queued by the `SettingsBuilder` when calling `load()`. If a cache interface has been provided, and the source is considered cacheable (implements `CacheableSource`), then it is wrapped as a `CachedSource` which will query the cache first before loading from the wrapped source. Cache stampedes are mitigated using probabilistic early expiry. The implementation for this was partially based on symfony/cache-contract source code but also from the Wikipedia article and paper referenced therein. See https://en.wikipedia.org/wiki/Cache_stampede#Probabilistic_early_expiration Bug: T294748 Change-Id: I52ab3899731546876ee58265bd4a1927886746dc
* Introduced settings sources and formatsDan Duvall2021-11-151-0/+25
A `SettingsSource` is meant to represent any kind of local or remote store from which settings can be read, be this a local file, remote URL, database, etc. It is concerned with reading in (and possibly decoding) settings data, and computing a consistent hash key that may be used in caching. A `SettingsFormat` is meant to detect supported file types and/or decode source contents into settings arrays. As of now, JSON is the only supported format but others may be implemented. `FileSource` is the first source implementation, with its default format being JSON, meant to read settings from local JSON files. `ArraySource` is mostly useful for testing using array literals. Refactored `SettingsBuilder` methods to use the new source abstractions. Bug: T295499 Change-Id: If7869609c4ad1ccd0894d5ba358f885007168972