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" );
261 return MediaWikiServices::getInstance()->getMainConfig();
285 $this->value = constant(
$name );
storeToCache($cache, $key, $expiry=0)
Store the wrapper to a cache.
static getValueFromCache($cache, $key, $expiry=0, $callback=false, $callbackParams=[], $deps=[])
Attempt to get a value from the cache.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This class stores an arbitrary value along with its dependencies.
getValue()
Get the user-defined value.
__construct($filename, $timestamp=null)
Create a file dependency.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
isExpired()
Returns true if the dependency is expired, false otherwise.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
__construct($value=false, $deps=[])
Create an instance.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
loadDependencyValues()
Hook to perform any expensive pre-serialize loading of dependency values.
initialiseDeps()
Initialise dependency values in preparation for storing.
isExpired()
Returns true if any of the dependencies have expired.