X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcache%2FFileCacheBase.php;h=5632596a435b2c0b8d3b6c9383e715d42a39130d;hb=9964ca1a390c446397dcd466916ffed356cdc3c9;hp=0c00c6b59367327c259daa3c087b3c8daa76dacf;hpb=665f171a18061aacd339102a21f32d714c5de50d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php index 0c00c6b593..e25f882b37 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 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() { - wfSuppressWarnings(); + MediaWiki\suppressWarnings(); unlink( $this->cachePath() ); - wfRestoreWarnings(); + MediaWiki\restoreWarnings(); $this->mCached = false; } @@ -231,12 +225,12 @@ abstract class FileCacheBase { /** * Roughly increments the cache misses in the last hour by unique visitors - * @param $request WebRequest + * @param WebRequest $request * @return void */ public function incrMissesRecent( WebRequest $request ) { - global $wgMemc; if ( mt_rand( 0, self::MISS_FACTOR - 1 ) == 0 ) { + $cache = ObjectCache::getLocalClusterInstance(); # Get a large IP range that should include the user even if that # person's IP address changes $ip = $request->getIP(); @@ -249,17 +243,17 @@ abstract class FileCacheBase { # Bail out if a request already came from this range... $key = wfMemcKey( get_class( $this ), 'attempt', $this->mType, $this->mKey, $ip ); - if ( $wgMemc->get( $key ) ) { + if ( $cache->get( $key ) ) { return; // possibly the same user } - $wgMemc->set( $key, 1, self::MISS_TTL_SEC ); + $cache->set( $key, 1, self::MISS_TTL_SEC ); # Increment the number of cache misses... $key = $this->cacheMissKey(); - if ( $wgMemc->get( $key ) === false ) { - $wgMemc->set( $key, 1, self::MISS_TTL_SEC ); + if ( $cache->get( $key ) === false ) { + $cache->set( $key, 1, self::MISS_TTL_SEC ); } else { - $wgMemc->incr( $key ); + $cache->incr( $key ); } } } @@ -269,9 +263,9 @@ abstract class FileCacheBase { * @return int */ public function getMissesRecent() { - global $wgMemc; + $cache = ObjectCache::getLocalClusterInstance(); - return self::MISS_FACTOR * $wgMemc->get( $this->cacheMissKey() ); + return self::MISS_FACTOR * $cache->get( $this->cacheMissKey() ); } /**