X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fcache%2FFileCacheBase.php;h=ce5a019b7cd8b8ac98d9656752a8f1155fdfed1f;hb=fbc9e214e7c6f687e7dc3a3178e60f4164ed9ad6;hp=360420b615b7f1cdf1726b8f711eacd98a9a2fc0;hpb=8ab6c38d4f03986cd4b581a93d6402371f4cf801;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php index 360420b615..ce5a019b7c 100644 --- a/includes/cache/FileCacheBase.php +++ b/includes/cache/FileCacheBase.php @@ -154,15 +154,9 @@ abstract class FileCacheBase { /** * Save and compress text to the cache * @param string $text - * @return string Compressed text + * @return string|false Compressed text */ public function saveText( $text ) { - global $wgUseFileCache; - - if ( !$wgUseFileCache ) { - return false; - } - if ( $this->useGzip() ) { $text = gzencode( $text ); } @@ -185,9 +179,9 @@ abstract class FileCacheBase { * @return void */ public function clearCache() { - MediaWiki\suppressWarnings(); + Wikimedia\suppressWarnings(); unlink( $this->cachePath() ); - MediaWiki\restoreWarnings(); + Wikimedia\restoreWarnings(); $this->mCached = false; } @@ -248,14 +242,14 @@ abstract class FileCacheBase { : IP::sanitizeRange( "$ip/16" ); # Bail out if a request already came from this range... - $key = wfMemcKey( get_class( $this ), 'attempt', $this->mType, $this->mKey, $ip ); + $key = $cache->makeKey( static::class, 'attempt', $this->mType, $this->mKey, $ip ); if ( $cache->get( $key ) ) { return; // possibly the same user } $cache->set( $key, 1, self::MISS_TTL_SEC ); # Increment the number of cache misses... - $key = $this->cacheMissKey(); + $key = $this->cacheMissKey( $cache ); if ( $cache->get( $key ) === false ) { $cache->set( $key, 1, self::MISS_TTL_SEC ); } else { @@ -271,13 +265,14 @@ abstract class FileCacheBase { public function getMissesRecent() { $cache = ObjectCache::getLocalClusterInstance(); - return self::MISS_FACTOR * $cache->get( $this->cacheMissKey() ); + return self::MISS_FACTOR * $cache->get( $this->cacheMissKey( $cache ) ); } /** + * @param BagOStuff $cache Instance that the key will be used with * @return string */ - protected function cacheMissKey() { - return wfMemcKey( get_class( $this ), 'misses', $this->mType, $this->mKey ); + protected function cacheMissKey( BagOStuff $cache ) { + return $cache->makeKey( static::class, 'misses', $this->mType, $this->mKey ); } }