* @param BagOStuff $cache A cache object such as $wgMemc
* @param string $key The cache key
* @param int $expiry The expiry timestamp or interval in seconds
- * @param bool|array $callback The callback for generating the value, or false
+ * @param bool|callable $callback The callback for generating the value, or false
* @param array $callbackParams The function parameters for the callback
* @param array $deps The dependencies to store on a cache miss. Note: these
* are not the dependencies used on a cache hit! Cache hits use the stored
/**
* Create a file dependency
*
- * @param string $filename the name of the file, preferably fully qualified
+ * @param string $filename The name of the file, preferably fully qualified
* @param null|bool|int $timestamp The unix last modified timestamp, or false if the
* file does not exist. If omitted, the timestamp will be loaded from
* the file.
function loadDependencyValues() {
if ( is_null( $this->timestamp ) ) {
- if ( !file_exists( $this->filename ) ) {
- # Dependency on a non-existent file
- # This is a valid concept!
- $this->timestamp = false;
- } else {
- $this->timestamp = filemtime( $this->filename );
- }
+ MediaWiki\suppressWarnings();
+ # Dependency on a non-existent file stores "false"
+ # This is a valid concept!
+ $this->timestamp = filemtime( $this->filename );
+ MediaWiki\restoreWarnings();
}
}
* @return bool
*/
function isExpired() {
- if ( !file_exists( $this->filename ) ) {
+ MediaWiki\suppressWarnings();
+ $lastmod = filemtime( $this->filename );
+ MediaWiki\restoreWarnings();
+ if ( $lastmod === false ) {
if ( $this->timestamp === false ) {
# Still nonexistent
return false;
return true;
}
} else {
- $lastmod = filemtime( $this->filename );
if ( $lastmod > $this->timestamp ) {
# Modified or created
wfDebug( "Dependency triggered: {$this->filename} changed.\n" );