MtDu has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/355369 )
Change subject: Avoid deprecated ObjectCache::getMainWANInstance() ...................................................................... Avoid deprecated ObjectCache::getMainWANInstance() Use $this->wanCache->makeKey() instead of wfMemcKey() Change-Id: Iceda42ed4dc7ad30f97f42e0183df8e73f564b14 --- M includes/cache/FileCacheBase.php M includes/cache/MessageCache.php 2 files changed, 26 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/69/355369/1 diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php index 0a302b6..aecbb2e 100644 --- a/includes/cache/FileCacheBase.php +++ b/includes/cache/FileCacheBase.php @@ -21,6 +21,8 @@ * @ingroup Cache */ +use MediaWiki\MediaWikiServices; + /** * Base class for data storage in the file system. * @@ -242,7 +244,13 @@ : IP::sanitizeRange( "$ip/16" ); # Bail out if a request already came from this range... - $key = wfMemcKey( static::class, 'attempt', $this->mType, $this->mKey, $ip ); + $key = MediaWikiServices::getInstance()->getMainWANObjectCache()->makeKey( + static::class, + 'attempt', + $this->mType, + $this->mKey, + $ip + ); if ( $cache->get( $key ) ) { return; // possibly the same user } @@ -272,6 +280,11 @@ * @return string */ protected function cacheMissKey() { - return wfMemcKey( static::class, 'misses', $this->mType, $this->mKey ); + return MediaWikiServices::getInstance()->getMainWANObjectCache()->makeKey( + static::class, + 'misses', + $this->mType, + $this->mKey + ); } } diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index 8f88ee9..a5dd77d 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -114,7 +114,6 @@ if ( self::$instance === null ) { global $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgUseLocalMessageCache; self::$instance = new self( - MediaWikiServices::getInstance()->getMainWANObjectCache(), wfGetMessageCacheStorage(), $wgUseLocalMessageCache ? MediaWikiServices::getInstance()->getLocalServerObjectCache() @@ -220,7 +219,7 @@ * @return array|bool The cache array, or false if not in cache. */ protected function getLocalCache( $code ) { - $cacheKey = wfMemcKey( __CLASS__, $code ); + $cacheKey = $this->wanCache->makeKey( __CLASS__, $code ); return $this->srvCache->get( $cacheKey ); } @@ -232,7 +231,7 @@ * @param array $cache The cache array */ protected function saveToLocalCache( $code, $cache ) { - $cacheKey = wfMemcKey( __CLASS__, $code ); + $cacheKey = $this->wanCache->makeKey( __CLASS__, $code ); $this->srvCache->set( $cacheKey, $cache ); } @@ -308,7 +307,7 @@ } if ( !$success ) { - $cacheKey = wfMemcKey( 'messages', $code ); # Key in memc for messages + $cacheKey = $this->wanCache->makeKey( 'messages', $code ); # Key in memc for messages # Try the global cache. If it is empty, try to acquire a lock. If # the lock can't be acquired, wait for the other thread to finish # and then try the global cache a second time. @@ -402,7 +401,7 @@ protected function loadFromDBWithLock( $code, array &$where, $mode = null ) { # If cache updates on all levels fail, give up on message overrides. # This is to avoid easy site outages; see $saveSuccess comments below. - $statusKey = wfMemcKey( 'messages', $code, 'status' ); + $statusKey = $this->wanCache->makeKey( 'messages', $code, 'status' ); $status = $this->clusterCache->get( $statusKey ); if ( $status === 'error' ) { $where[] = "could not load; method is still globally disabled"; @@ -416,7 +415,7 @@ # This lock is non-blocking so stale cache can quickly be used. # Note that load() will call a blocking getReentrantScopedLock() # after this if it really need to wait for any current thread. - $cacheKey = wfMemcKey( 'messages', $code ); + $cacheKey = $this->wanCache->makeKey( 'messages', $code ); $scopedLock = $this->getReentrantScopedLock( $cacheKey, 0 ); if ( !$scopedLock ) { $where[] = 'could not acquire main lock'; @@ -596,7 +595,7 @@ function () use ( $title, $msg, $code ) { global $wgContLang, $wgMaxMsgCacheEntrySize; // Allow one caller at a time to avoid race conditions - $scopedLock = $this->getReentrantScopedLock( wfMemcKey( 'messages', $code ) ); + $scopedLock = $this->getReentrantScopedLock( $this->wanCache->makeKey( 'messages', $code ) ); if ( !$scopedLock ) { LoggerFactory::getInstance( 'MessageCache' )->error( __METHOD__ . ': could not acquire lock to update {title} ({code})', @@ -628,7 +627,7 @@ // Relay the purge. Touching this check key expires cache contents // and local cache (APC) validation hash across all datacenters. - $this->wanCache->touchCheckKey( wfMemcKey( 'messages', $code ) ); + $this->wanCache->touchCheckKey( $this->wanCache->makeKey( 'messages', $code ) ); // Also delete cached sidebar... just in case it is affected // @TODO: shouldn't this be $code === $wgLanguageCode? if ( $code === 'en' ) { @@ -639,7 +638,7 @@ $codes = [ $code ]; } foreach ( $codes as $code ) { - $this->wanCache->delete( wfMemcKey( 'sidebar', $code ) ); + $this->wanCache->delete( $this->wanCache->makeKey( 'sidebar', $code ) ); } // Purge the message in the message blob store @@ -684,7 +683,7 @@ */ protected function saveToCaches( array $cache, $dest, $code = false ) { if ( $dest === 'all' ) { - $cacheKey = wfMemcKey( 'messages', $code ); + $cacheKey = $this->wanCache->makeKey( 'messages', $code ); $success = $this->clusterCache->set( $cacheKey, $cache ); $this->setValidationHash( $code, $cache ); } else { @@ -707,7 +706,7 @@ $value = $this->wanCache->get( $this->wanCache->makeKey( 'messages', $code, 'hash', 'v1' ), $curTTL, - [ wfMemcKey( 'messages', $code ) ] + [ $this->wanCache->makeKey( 'messages', $code ) ] ); if ( $value ) { @@ -1212,7 +1211,7 @@ $langs = Language::fetchLanguageNames( null, 'mw' ); foreach ( array_keys( $langs ) as $code ) { # Global and local caches - $this->wanCache->touchCheckKey( wfMemcKey( 'messages', $code ) ); + $this->wanCache->touchCheckKey( $this->wanCache->makeKey( 'messages', $code ) ); } $this->mLoadedLanguages = []; -- To view, visit https://gerrit.wikimedia.org/r/355369 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iceda42ed4dc7ad30f97f42e0183df8e73f564b14 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: MtDu <justin.d...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits