filename = $filename; $this->timestamp = $timestamp; } /** * @return array */ public function __sleep() { $this->loadDependencyValues(); return [ 'filename', 'timestamp' ]; } public function loadDependencyValues() { if ( $this->timestamp === null ) { Wikimedia\suppressWarnings(); # Dependency on a non-existent file stores "false" # This is a valid concept! $this->timestamp = filemtime( $this->filename ); Wikimedia\restoreWarnings(); } } /** * @return bool */ public function isExpired() { Wikimedia\suppressWarnings(); $lastmod = filemtime( $this->filename ); Wikimedia\restoreWarnings(); if ( $lastmod === false ) { if ( $this->timestamp === false ) { # Still nonexistent return false; } # Deleted wfDebug( "Dependency triggered: {$this->filename} deleted." ); return true; } if ( $lastmod > $this->timestamp ) { # Modified or created wfDebug( "Dependency triggered: {$this->filename} changed." ); return true; } # Not modified return false; } }