diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2023-08-29 15:49:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-29 15:49:23 +0200 |
commit | b9a493ed9bfb0730e45f7419f29a1e3a8864a29c (patch) | |
tree | da2d5d16cfe1d950863213bb3969f6e20760c7bb /lib | |
parent | ff0569abab7b6bd912e428d6ad21677c31c74059 (diff) | |
parent | 7ffc89e7ff34caeb60ba4afa567864966627b5a6 (diff) | |
download | nextcloud-server-b9a493ed9bfb0730e45f7419f29a1e3a8864a29c.tar.gz nextcloud-server-b9a493ed9bfb0730e45f7419f29a1e3a8864a29c.zip |
Merge pull request #40080 from nextcloud/backport/40077/stable27
[stable27] fix(cache): Remove displayname cache entry on delete
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Group/DisplayNameCache.php | 6 | ||||
-rw-r--r-- | lib/private/User/DisplayNameCache.php | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/private/Group/DisplayNameCache.php b/lib/private/Group/DisplayNameCache.php index d724b6caf0e..4eb8211be6e 100644 --- a/lib/private/Group/DisplayNameCache.php +++ b/lib/private/Group/DisplayNameCache.php @@ -29,6 +29,7 @@ use OCP\Cache\CappedMemoryCache; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\Group\Events\GroupChangedEvent; +use OCP\Group\Events\GroupDeletedEvent; use OCP\ICache; use OCP\ICacheFactory; use OCP\IGroupManager; @@ -83,5 +84,10 @@ class DisplayNameCache implements IEventListener { $this->cache[$groupId] = $newDisplayName; $this->memCache->set($groupId, $newDisplayName, 60 * 10); // 10 minutes } + if ($event instanceof GroupDeletedEvent) { + $groupId = $event->getGroup()->getGID(); + unset($this->cache[$groupId]); + $this->memCache->remove($groupId); + } } } diff --git a/lib/private/User/DisplayNameCache.php b/lib/private/User/DisplayNameCache.php index 5d1cc8940d7..6ee74cc9f6c 100644 --- a/lib/private/User/DisplayNameCache.php +++ b/lib/private/User/DisplayNameCache.php @@ -29,6 +29,7 @@ use OCP\ICache; use OCP\ICacheFactory; use OCP\IUserManager; use OCP\User\Events\UserChangedEvent; +use OCP\User\Events\UserDeletedEvent; /** * Class that cache the relation UserId -> Display name @@ -81,5 +82,10 @@ class DisplayNameCache implements IEventListener { $this->cache[$userId] = $newDisplayName; $this->memCache->set($userId, $newDisplayName, 60 * 10); // 10 minutes } + if ($event instanceof UserDeletedEvent) { + $userId = $event->getUser()->getUID(); + unset($this->cache[$userId]); + $this->memCache->remove($userId); + } } } |