Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/200823

Change subject: Rely less on file stat cache in FileDependency
......................................................................

Rely less on file stat cache in FileDependency

Change-Id: Ica16ddb7db00a56a16332c4dbb9a04e7b40a1844
---
M includes/cache/CacheDependency.php
1 file changed, 10 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/23/200823/1

diff --git a/includes/cache/CacheDependency.php 
b/includes/cache/CacheDependency.php
index 9b48ecb..3c87c78 100644
--- a/includes/cache/CacheDependency.php
+++ b/includes/cache/CacheDependency.php
@@ -181,12 +181,16 @@
 
        function loadDependencyValues() {
                if ( is_null( $this->timestamp ) ) {
-                       if ( !file_exists( $this->filename ) ) {
+                       wfSuppressWarnings();
+                       $lastmod = filemtime( $this->filename );
+                       wfRestoreWarnings();
+
+                       if ( $lastmod === false ) {
                                # Dependency on a non-existent file
                                # This is a valid concept!
                                $this->timestamp = false;
                        } else {
-                               $this->timestamp = filemtime( $this->filename );
+                               $this->timestamp = $lastmod;
                        }
                }
        }
@@ -195,7 +199,10 @@
         * @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 +213,6 @@
                                return true;
                        }
                } else {
-                       $lastmod = filemtime( $this->filename );
                        if ( $lastmod > $this->timestamp ) {
                                # Modified or created
                                wfDebug( "Dependency triggered: 
{$this->filename} changed.\n" );

-- 
To view, visit https://gerrit.wikimedia.org/r/200823
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica16ddb7db00a56a16332c4dbb9a04e7b40a1844
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to