X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcache%2FMessageCache.php;h=f9f9a08a33d5a77a256e2515923b0f44f5f7c533;hb=a8dcb178c7e347ef56bef1e36bb4a26a61a1d82b;hp=c99211206825e7cf07ab67a4288edf2878cc803f;hpb=f0a80ea778057379a16e277348ab5e11d939b137;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index c992112068..f9f9a08a33 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -220,7 +220,7 @@ class MessageCache { * @return array|bool The cache array, or false if not in cache. */ protected function getLocalCache( $code ) { - $cacheKey = wfMemcKey( __CLASS__, $code ); + $cacheKey = $this->srvCache->makeKey( __CLASS__, $code ); return $this->srvCache->get( $cacheKey ); } @@ -232,7 +232,7 @@ class MessageCache { * @param array $cache The cache array */ protected function saveToLocalCache( $code, $cache ) { - $cacheKey = wfMemcKey( __CLASS__, $code ); + $cacheKey = $this->srvCache->makeKey( __CLASS__, $code ); $this->srvCache->set( $cacheKey, $cache ); } @@ -308,7 +308,7 @@ class MessageCache { } if ( !$success ) { - $cacheKey = wfMemcKey( 'messages', $code ); # Key in memc for messages + $cacheKey = $this->clusterCache->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 +402,7 @@ class MessageCache { 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->clusterCache->makeKey( 'messages', $code, 'status' ); $status = $this->clusterCache->get( $statusKey ); if ( $status === 'error' ) { $where[] = "could not load; method is still globally disabled"; @@ -416,7 +416,7 @@ class MessageCache { # 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->clusterCache->makeKey( 'messages', $code ); $scopedLock = $this->getReentrantScopedLock( $cacheKey, 0 ); if ( !$scopedLock ) { $where[] = 'could not acquire main lock'; @@ -464,7 +464,11 @@ class MessageCache { protected function loadFromDB( $code, $mode = null ) { global $wgMaxMsgCacheEntrySize, $wgLanguageCode, $wgAdaptiveMessageCache; - $dbr = wfGetDB( ( $mode == self::FOR_UPDATE ) ? DB_MASTER : DB_REPLICA ); + // (T164666) The query here performs really poorly on WMF's + // contributions replicas. We don't have a way to say "any group except + // contributions", so for the moment let's specify 'api'. + // @todo: Get rid of this hack. + $dbr = wfGetDB( ( $mode == self::FOR_UPDATE ) ? DB_MASTER : DB_REPLICA, 'api' ); $cache = []; @@ -592,7 +596,9 @@ class MessageCache { 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->clusterCache->makeKey( 'messages', $code ) + ); if ( !$scopedLock ) { LoggerFactory::getInstance( 'MessageCache' )->error( __METHOD__ . ': could not acquire lock to update {title} ({code})', @@ -624,7 +630,7 @@ class MessageCache { // 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' ) { @@ -635,7 +641,7 @@ class MessageCache { $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 @@ -680,7 +686,7 @@ class MessageCache { */ protected function saveToCaches( array $cache, $dest, $code = false ) { if ( $dest === 'all' ) { - $cacheKey = wfMemcKey( 'messages', $code ); + $cacheKey = $this->clusterCache->makeKey( 'messages', $code ); $success = $this->clusterCache->set( $cacheKey, $cache ); $this->setValidationHash( $code, $cache ); } else { @@ -703,7 +709,7 @@ class MessageCache { $value = $this->wanCache->get( $this->wanCache->makeKey( 'messages', $code, 'hash', 'v1' ), $curTTL, - [ wfMemcKey( 'messages', $code ) ] + [ $this->wanCache->makeKey( 'messages', $code ) ] ); if ( $value ) { @@ -810,7 +816,7 @@ class MessageCache { } // Normalise title-case input (with some inlining) - $lckey = MessageCache::normalizeKey( $key ); + $lckey = self::normalizeKey( $key ); Hooks::run( 'MessageCache::get', [ &$lckey ] ); @@ -1208,7 +1214,7 @@ class MessageCache { $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 = [];