aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_sharing/lib/AppInfo/Application.php4
-rw-r--r--lib/private/Group/DisplayNameCache.php6
-rw-r--r--lib/private/User/DisplayNameCache.php6
3 files changed, 16 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php
index b76239dc00d..603527310ae 100644
--- a/apps/files_sharing/lib/AppInfo/Application.php
+++ b/apps/files_sharing/lib/AppInfo/Application.php
@@ -65,12 +65,14 @@ use OCP\Files\Events\BeforeDirectFileDownloadEvent;
use OCP\Files\Events\BeforeZipCreatedEvent;
use OCP\Files\IRootFolder;
use OCP\Group\Events\GroupChangedEvent;
+use OCP\Group\Events\GroupDeletedEvent;
use OCP\Group\Events\UserAddedEvent;
use OCP\IDBConnection;
use OCP\IGroup;
use OCP\IUserSession;
use OCP\Share\Events\ShareCreatedEvent;
use OCP\User\Events\UserChangedEvent;
+use OCP\User\Events\UserDeletedEvent;
use OCP\Util;
use Psr\Container\ContainerInterface;
use Symfony\Component\EventDispatcher\GenericEvent as OldGenericEvent;
@@ -104,7 +106,9 @@ class Application extends App implements IBootstrap {
$context->registerNotifierService(Notifier::class);
$context->registerEventListener(UserChangedEvent::class, DisplayNameCache::class);
+ $context->registerEventListener(UserDeletedEvent::class, DisplayNameCache::class);
$context->registerEventListener(GroupChangedEvent::class, GroupDisplayNameCache::class);
+ $context->registerEventListener(GroupDeletedEvent::class, GroupDisplayNameCache::class);
}
public function boot(IBootContext $context): void {
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);
+ }
}
}