From: Aaron Schulz Date: Thu, 19 Jul 2018 10:02:57 +0000 (+0100) Subject: Avoid passing "false" as keys to MapCacheLRU in RepoGroup X-Git-Tag: 1.34.0-rc.0~4702^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=88b69410f933bbda996cb3230e58e1c6cc85eecc;p=lhc%2Fweb%2Fwiklou.git Avoid passing "false" as keys to MapCacheLRU in RepoGroup Bug: T200026 Change-Id: I40f6ad2a3d281d06c9b6eaf4f31d9796ea5e9e9e --- diff --git a/includes/filerepo/RepoGroup.php b/includes/filerepo/RepoGroup.php index 90c8707f8d..f3fed5772d 100644 --- a/includes/filerepo/RepoGroup.php +++ b/includes/filerepo/RepoGroup.php @@ -125,10 +125,12 @@ class RepoGroup { if ( isset( $options['bypassCache'] ) ) { $options['latest'] = $options['bypassCache']; // b/c } + $options += [ 'time' => false ]; if ( !$this->reposInitialised ) { $this->initialiseRepos(); } + $title = File::normalizeTitle( $title ); if ( !$title ) { return false; @@ -136,17 +138,16 @@ class RepoGroup { # Check the cache $dbkey = $title->getDBkey(); + $timeKey = is_string( $options['time'] ) ? $options['time'] : ''; if ( empty( $options['ignoreRedirect'] ) && empty( $options['private'] ) && empty( $options['latest'] ) ) { - $time = $options['time'] ?? ''; - if ( $this->cache->hasField( $dbkey, $time, 60 ) ) { - return $this->cache->getField( $dbkey, $time ); + if ( $this->cache->hasField( $dbkey, $timeKey, 60 ) ) { + return $this->cache->getField( $dbkey, $timeKey ); } $useCache = true; } else { - $time = false; $useCache = false; } @@ -166,7 +167,7 @@ class RepoGroup { $image = $image ?: false; // type sanity # Cache file existence or non-existence if ( $useCache && ( !$image || $image->isCacheable() ) ) { - $this->cache->setField( $dbkey, $time, $image ); + $this->cache->setField( $dbkey, $timeKey, $image ); } return $image;