From: Ori Livneh Date: Thu, 24 Apr 2014 22:57:09 +0000 (-0700) Subject: Simplify LocalFile::isVolatile X-Git-Tag: 1.31.0-rc.0~16014^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dcompta/operations/modifier.php?a=commitdiff_plain;h=776d0900b96870d94b08cb592931c05580fe9153;p=lhc%2Fweb%2Fwiklou.git Simplify LocalFile::isVolatile Make the logic a bit easier to follow. Follow-up to I99a39c3d2. Change-Id: I9b815d7f0d229ef25db5b7f48f6e49ca4dac046e --- 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; } /**