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