From 8d2f7b9178205bc9892602384af94ebbb8bbfce1 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 25 Jan 2015 01:19:24 -0800 Subject: [PATCH] Never treat persistent stat cache as "latest" in FileBackend bug: T89184 Change-Id: I035c0f85a641efa0e4e3209b2bcf9847c08ab0d2 --- includes/filebackend/FileBackend.php | 2 ++ includes/filebackend/FileBackendStore.php | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/includes/filebackend/FileBackend.php b/includes/filebackend/FileBackend.php index 95041125ce..b87e26d3fe 100644 --- a/includes/filebackend/FileBackend.php +++ b/includes/filebackend/FileBackend.php @@ -1204,7 +1204,9 @@ abstract class FileBackend { /** * Preload file stat information (concurrently if possible) into in-process cache. + * * This should be used when stat calls will be made on a known list of a many files. + * This does not make use of the persistent file stat cache. * * @see FileBackend::getFileStat() * diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php index a3b0009b8a..de189ec7e0 100644 --- a/includes/filebackend/FileBackendStore.php +++ b/includes/filebackend/FileBackendStore.php @@ -627,7 +627,7 @@ abstract class FileBackendStore extends FileBackend { } $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $latest = !empty( $params['latest'] ); // use latest data? - if ( !$this->cheapCache->has( $path, 'stat', self::CACHE_TTL ) ) { + if ( !$latest && !$this->cheapCache->has( $path, 'stat', self::CACHE_TTL ) ) { $this->primeFileCache( array( $path ) ); // check persistent cache } if ( $this->cheapCache->has( $path, 'stat', self::CACHE_TTL ) ) { @@ -1745,17 +1745,18 @@ abstract class FileBackendStore extends FileBackend { // Get all cache entries for these container cache keys... $values = $this->memCache->getMulti( array_keys( $pathNames ) ); foreach ( $values as $cacheKey => $val ) { + $path = $pathNames[$cacheKey]; if ( is_array( $val ) ) { - $path = $pathNames[$cacheKey]; + $val['latest'] = false; // never completely trust cache $this->cheapCache->set( $path, 'stat', $val ); if ( isset( $val['sha1'] ) ) { // some backends store SHA-1 as metadata $this->cheapCache->set( $path, 'sha1', - array( 'hash' => $val['sha1'], 'latest' => $val['latest'] ) ); + array( 'hash' => $val['sha1'], 'latest' => false ) ); } if ( isset( $val['xattr'] ) ) { // some backends store headers/metadata $val['xattr'] = self::normalizeXAttributes( $val['xattr'] ); $this->cheapCache->set( $path, 'xattr', - array( 'map' => $val['xattr'], 'latest' => $val['latest'] ) ); + array( 'map' => $val['xattr'], 'latest' => false ) ); } } } -- 2.20.1