mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 09:13:19 -04:00
Merge pull request #40085 from nextcloud/backport/40077/stable26
[stable26] fix(cache): Remove displayname cache entry on delete
This commit is contained in:
commit
4230aa8dd3
3 changed files with 16 additions and 0 deletions
|
|
@ -68,6 +68,7 @@ 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;
|
||||
|
|
@ -76,6 +77,7 @@ use OCP\L10N\IFactory;
|
|||
use OCP\Share\Events\ShareCreatedEvent;
|
||||
use OCP\Share\IManager;
|
||||
use OCP\User\Events\UserChangedEvent;
|
||||
use OCP\User\Events\UserDeletedEvent;
|
||||
use OCP\Util;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
|
@ -110,7 +112,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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue