From 776d0900b96870d94b08cb592931c05580fe9153 Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Thu, 24 Apr 2014 15:57:09 -0700 Subject: [PATCH] Simplify LocalFile::isVolatile Make the logic a bit easier to follow. Follow-up to I99a39c3d2. Change-Id: I9b815d7f0d229ef25db5b7f48f6e49ca4dac046e --- includes/filerepo/file/LocalFile.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 5fd5512dd1..e3b73e359e 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1929,18 +1929,17 @@ class LocalFile extends File { global $wgMemc; $key = $this->repo->getSharedCacheKey( 'file-volatile', md5( $this->getName() ) ); - if ( $key ) { - if ( $this->lastMarkedVolatile - && ( time() - $this->lastMarkedVolatile ) <= self::VOLATILE_TTL - ) { - return true; // sanity - } - $volatileTimestamp = (int)$wgMemc->get( $key ); - $this->lastMarkedVolatile = max( $this->lastMarkedVolatile, $volatileTimestamp ); - return ( $volatileTimestamp != 0 ); + if ( !$key ) { + // repo unavailable; bail. + return false; + } + + if ( $this->lastMarkedVolatile === 0 ) { + $this->lastMarkedVolatile = $wgMemc->get( $key ) ?: 0; } - return false; + $volatileDuration = time() - $this->lastMarkedVolatile; + return $volatileDuration <= self::VOLATILE_TTL; } /** -- 2.20.1