45 if ( !is_array(
$deps ) ) {
58 foreach ( $this->deps as $dep ) {
59 if ( $dep->isExpired() ) {
72 foreach ( $this->deps as $dep ) {
73 $dep->loadDependencyValues();
94 $cache->set( $key, $this, $expiry );
115 $callbackParams = [],
$deps = []
117 $obj =
$cache->get( $key );
121 } elseif ( $callback ) {
122 $value = call_user_func_array( $callback, $callbackParams );
123 # Cache the newly-generated value
125 $wrapper->storeToCache(
$cache, $key, $expiry );
180 return [
'filename',
'timestamp' ];
184 if ( is_null( $this->timestamp ) ) {
185 MediaWiki\suppressWarnings();
186 # Dependency on a non-existent file stores "false"
187 # This is a valid concept!
188 $this->timestamp = filemtime( $this->filename );
189 MediaWiki\restoreWarnings();
197 MediaWiki\suppressWarnings();
198 $lastmod = filemtime( $this->filename );
199 MediaWiki\restoreWarnings();
200 if ( $lastmod ===
false ) {
201 if ( $this->timestamp ===
false ) {
206 wfDebug(
"Dependency triggered: {$this->filename} deleted.\n" );
211 if ( $lastmod > $this->timestamp ) {
212 # Modified or created
213 wfDebug(
"Dependency triggered: {$this->filename} changed.\n" );
240 if ( !isset(
$GLOBALS[$this->name] ) ) {
257 $this->value = $this->
getConfig()->get( $this->name );
261 return MediaWikiServices::getInstance()->getMainConfig();
268 if ( !$this->
getConfig()->has( $this->name ) ) {
285 $this->value = constant( $name );
$GLOBALS['wgAutoloadClasses']['LocalisationUpdate']
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
loadDependencyValues()
Hook to perform any expensive pre-serialize loading of dependency values.
isExpired()
Returns true if the dependency is expired, false otherwise.
This class stores an arbitrary value along with its dependencies.
__construct( $value=false, $deps=[])
Create an instance.
initialiseDeps()
Initialise dependency values in preparation for storing.
static getValueFromCache( $cache, $key, $expiry=0, $callback=false, $callbackParams=[], $deps=[])
Attempt to get a value from the cache.
storeToCache( $cache, $key, $expiry=0)
Store the wrapper to a cache.
getValue()
Get the user-defined value.
isExpired()
Returns true if any of the dependencies have expired.
__construct( $filename, $timestamp=null)
Create a file dependency.
loadDependencyValues()
Hook to perform any expensive pre-serialize loading of dependency values.