From fa21b7b0cd350b11d02531378f38c1d48a045ff0 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Thu, 31 May 2018 16:01:57 -0700 Subject: [PATCH] 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 --- includes/NotifUser.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/includes/NotifUser.php b/includes/NotifUser.php index 354f9172a..eeee4168c 100644 --- a/includes/NotifUser.php +++ b/includes/NotifUser.php @@ -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.