Merge "Fixed wrong EnqueueJob comment"
[lhc/web/wiklou.git] / includes / cache / CacheDependency.php
index 15d7c89..517f379 100644 (file)
@@ -156,7 +156,7 @@ class FileDependency extends CacheDependency {
        /**
         * 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.
@@ -181,13 +181,11 @@ class FileDependency extends CacheDependency {
 
        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 );
-                       }
+                       wfSuppressWarnings();
+                       # Dependency on a non-existent file stores "false"
+                       # This is a valid concept!
+                       $this->timestamp = filemtime( $this->filename );
+                       wfRestoreWarnings();
                }
        }
 
@@ -195,7 +193,10 @@ class FileDependency extends CacheDependency {
         * @return bool
         */
        function isExpired() {
-               if ( !file_exists( $this->filename ) ) {
+               wfSuppressWarnings();
+               $lastmod = filemtime( $this->filename );
+               wfRestoreWarnings();
+               if ( $lastmod === false ) {
                        if ( $this->timestamp === false ) {
                                # Still nonexistent
                                return false;
@@ -206,7 +207,6 @@ class FileDependency extends CacheDependency {
                                return true;
                        }
                } else {
-                       $lastmod = filemtime( $this->filename );
                        if ( $lastmod > $this->timestamp ) {
                                # Modified or created
                                wfDebug( "Dependency triggered: {$this->filename} changed.\n" );