NotifUser: Un-merge getMemcKey() and getGlobalMemcKey()

We used to have code that called getMemcKey() with a boolean parameter
deciding whether to get a local or global key, but we don't do that
anymore: every code path now knows whether it needs a local or global
key. Consequently, move the code for global cache key generation back to
getGlobalMemcKey(), rather than having both be in getMemcKey() and
getGlobalMemcKey() being a wrapper.

Change-Id: If35bafc53e1e0086c31fd9675a9dc057e36f5717
This commit is contained in:
Roan Kattouw 2018-05-31 16:01:57 -07:00
parent d90e2d1066
commit fa21b7b0cd

View file

@ -612,17 +612,24 @@ class MWEchoNotifUser {
}
/**
* Build a memcached key.
* Build a cache key for local use (local to this wiki)
*
* @param string $key Key, typically prefixed with echo-notification-
* @param bool $global If true, return a global memc key; if false, return one local to this wiki
* @return string|false Memcached key, or false if one could not be generated (can only happen for global keys)
* @return string Cache key
*/
protected function getMemcKey( $key, $global = false ) {
protected function getMemcKey( $key ) {
global $wgEchoCacheVersion;
if ( !$global ) {
return wfMemcKey( $key, $this->mUser->getId(), $wgEchoCacheVersion );
}
return wfMemcKey( $key, $this->mUser->getId(), $wgEchoCacheVersion );
}
/**
* Build a cache key for global use
*
* @param string $key Key, typically prefixed with echo-notification-
* @return string|false Memcached key, or false if one could not be generated
*/
protected function getGlobalMemcKey( $key ) {
global $wgEchoCacheVersion;
$lookup = CentralIdLookup::factory();
$globalId = $lookup->centralIdFromLocalUser( $this->mUser, CentralIdLookup::AUDIENCE_RAW );
if ( !$globalId ) {
@ -631,10 +638,6 @@ class MWEchoNotifUser {
return wfGlobalCacheKey( $key, $globalId, $wgEchoCacheVersion );
}
protected function getGlobalMemcKey( $key ) {
return $this->getMemcKey( $key, true );
}
/**
* Lazy-construct an EchoForeignNotifications instance. This instance is force-enabled, so it
* returns information about cross-wiki notifications even if the user has them disabled.