From 7c4ceb444cb22f519cd30af5cd22304b960c8818 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Thu, 3 Nov 2022 12:51:29 +0100 Subject: [PATCH] Add group display name cache Signed-off-by: Anna Larch --- .../files_sharing/lib/AppInfo/Application.php | 3 + lib/composer/composer/autoload_classmap.php | 2 + lib/composer/composer/autoload_static.php | 2 + lib/private/Group/DisplayNameCache.php | 87 +++++++++++++++++ lib/private/Group/Group.php | 2 + lib/private/Group/Manager.php | 17 +++- lib/private/Server.php | 3 +- lib/public/Group/Events/GroupChangedEvent.php | 94 +++++++++++++++++++ lib/public/IGroupManager.php | 10 ++ tests/lib/Group/ManagerTest.php | 62 ++++++------ 10 files changed, 250 insertions(+), 32 deletions(-) create mode 100644 lib/private/Group/DisplayNameCache.php create mode 100644 lib/public/Group/Events/GroupChangedEvent.php diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 63fdced9011..960d376c6d3 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -29,6 +29,7 @@ */ namespace OCA\Files_Sharing\AppInfo; +use OC\Group\DisplayNameCache as GroupDisplayNameCache; use OC\Share\Share; use OC\User\DisplayNameCache; use OCA\Files_Sharing\Capabilities; @@ -66,6 +67,7 @@ use OCP\Files\Config\IMountProviderCollection; use OCP\Files\Events\BeforeDirectFileDownloadEvent; use OCP\Files\Events\BeforeZipCreatedEvent; use OCP\Files\IRootFolder; +use OCP\Group\Events\GroupChangedEvent; use OCP\Group\Events\UserAddedEvent; use OCP\IDBConnection; use OCP\IGroup; @@ -108,6 +110,7 @@ class Application extends App implements IBootstrap { $context->registerNotifierService(Notifier::class); $context->registerEventListener(UserChangedEvent::class, DisplayNameCache::class); + $context->registerEventListener(GroupChangedEvent::class, GroupDisplayNameCache::class); } public function boot(IBootContext $context): void { diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index d8016e10b79..90e7fe51fa7 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -402,6 +402,7 @@ return array( 'OCP\\Group\\Events\\BeforeGroupDeletedEvent' => $baseDir . '/lib/public/Group/Events/BeforeGroupDeletedEvent.php', 'OCP\\Group\\Events\\BeforeUserAddedEvent' => $baseDir . '/lib/public/Group/Events/BeforeUserAddedEvent.php', 'OCP\\Group\\Events\\BeforeUserRemovedEvent' => $baseDir . '/lib/public/Group/Events/BeforeUserRemovedEvent.php', + 'OCP\\Group\\Events\\GroupChangedEvent' => $baseDir . '/lib/public/Group/Events/GroupChangedEvent.php', 'OCP\\Group\\Events\\GroupCreatedEvent' => $baseDir . '/lib/public/Group/Events/GroupCreatedEvent.php', 'OCP\\Group\\Events\\GroupDeletedEvent' => $baseDir . '/lib/public/Group/Events/GroupDeletedEvent.php', 'OCP\\Group\\Events\\SubAdminAddedEvent' => $baseDir . '/lib/public/Group/Events/SubAdminAddedEvent.php', @@ -1280,6 +1281,7 @@ return array( 'OC\\GlobalScale\\Config' => $baseDir . '/lib/private/GlobalScale/Config.php', 'OC\\Group\\Backend' => $baseDir . '/lib/private/Group/Backend.php', 'OC\\Group\\Database' => $baseDir . '/lib/private/Group/Database.php', + 'OC\\Group\\DisplayNameCache' => $baseDir . '/lib/private/Group/DisplayNameCache.php', 'OC\\Group\\Group' => $baseDir . '/lib/private/Group/Group.php', 'OC\\Group\\Manager' => $baseDir . '/lib/private/Group/Manager.php', 'OC\\Group\\MetaData' => $baseDir . '/lib/private/Group/MetaData.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 595c7ec3736..8cef29efc39 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -435,6 +435,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Group\\Events\\BeforeGroupDeletedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/BeforeGroupDeletedEvent.php', 'OCP\\Group\\Events\\BeforeUserAddedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/BeforeUserAddedEvent.php', 'OCP\\Group\\Events\\BeforeUserRemovedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/BeforeUserRemovedEvent.php', + 'OCP\\Group\\Events\\GroupChangedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/GroupChangedEvent.php', 'OCP\\Group\\Events\\GroupCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/GroupCreatedEvent.php', 'OCP\\Group\\Events\\GroupDeletedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/GroupDeletedEvent.php', 'OCP\\Group\\Events\\SubAdminAddedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/SubAdminAddedEvent.php', @@ -1313,6 +1314,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\GlobalScale\\Config' => __DIR__ . '/../../..' . '/lib/private/GlobalScale/Config.php', 'OC\\Group\\Backend' => __DIR__ . '/../../..' . '/lib/private/Group/Backend.php', 'OC\\Group\\Database' => __DIR__ . '/../../..' . '/lib/private/Group/Database.php', + 'OC\\Group\\DisplayNameCache' => __DIR__ . '/../../..' . '/lib/private/Group/DisplayNameCache.php', 'OC\\Group\\Group' => __DIR__ . '/../../..' . '/lib/private/Group/Group.php', 'OC\\Group\\Manager' => __DIR__ . '/../../..' . '/lib/private/Group/Manager.php', 'OC\\Group\\MetaData' => __DIR__ . '/../../..' . '/lib/private/Group/MetaData.php', diff --git a/lib/private/Group/DisplayNameCache.php b/lib/private/Group/DisplayNameCache.php new file mode 100644 index 00000000000..d724b6caf0e --- /dev/null +++ b/lib/private/Group/DisplayNameCache.php @@ -0,0 +1,87 @@ + + * @author Anna Larch + * + * @license AGPL-3.0-or-later + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + + +namespace OC\Group; + +use OCP\Cache\CappedMemoryCache; +use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventListener; +use OCP\Group\Events\GroupChangedEvent; +use OCP\ICache; +use OCP\ICacheFactory; +use OCP\IGroupManager; + +/** + * Class that cache the relation Group ID -> Display name + * + * This saves fetching the group from the backend for "just" the display name + */ +class DisplayNameCache implements IEventListener { + private CappedMemoryCache $cache; + private ICache $memCache; + private IGroupManager $groupManager; + + public function __construct(ICacheFactory $cacheFactory, IGroupManager $groupManager) { + $this->cache = new CappedMemoryCache(); + $this->memCache = $cacheFactory->createDistributed('groupDisplayNameMappingCache'); + $this->groupManager = $groupManager; + } + + public function getDisplayName(string $groupId): ?string { + if (isset($this->cache[$groupId])) { + return $this->cache[$groupId]; + } + $displayName = $this->memCache->get($groupId); + if ($displayName) { + $this->cache[$groupId] = $displayName; + return $displayName; + } + + $group = $this->groupManager->get($groupId); + if ($group) { + $displayName = $group->getDisplayName(); + } else { + $displayName = null; + } + $this->cache[$groupId] = $displayName; + $this->memCache->set($groupId, $displayName, 60 * 10); // 10 minutes + + return $displayName; + } + + public function clear(): void { + $this->cache = new CappedMemoryCache(); + $this->memCache->clear(); + } + + public function handle(Event $event): void { + if ($event instanceof GroupChangedEvent && $event->getFeature() === 'displayName') { + $groupId = $event->getGroup()->getGID(); + $newDisplayName = $event->getValue(); + $this->cache[$groupId] = $newDisplayName; + $this->memCache->set($groupId, $newDisplayName, 60 * 10); // 10 minutes + } + } +} diff --git a/lib/private/Group/Group.php b/lib/private/Group/Group.php index 2ef4d2ee23f..ae70a611e4e 100644 --- a/lib/private/Group/Group.php +++ b/lib/private/Group/Group.php @@ -38,6 +38,7 @@ use OCP\Group\Backend\IGetDisplayNameBackend; use OCP\Group\Backend\IHideFromCollaborationBackend; use OCP\Group\Backend\INamedBackend; use OCP\Group\Backend\ISetDisplayNameBackend; +use OCP\Group\Events\GroupChangedEvent; use OCP\GroupInterface; use OCP\IGroup; use OCP\IUser; @@ -112,6 +113,7 @@ class Group implements IGroup { if (($backend instanceof ISetDisplayNameBackend) && $backend->setDisplayName($this->gid, $displayName)) { $this->displayName = $displayName; + $this->dispatcher->dispatch(new GroupChangedEvent($this, 'displayName', $displayName, '')); return true; } } diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index 28f7a400b41..b718afa5168 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -42,6 +42,7 @@ namespace OC\Group; use OC\Hooks\PublicEmitter; use OCP\EventDispatcher\IEventDispatcher; use OCP\GroupInterface; +use OCP\ICacheFactory; use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; @@ -82,12 +83,16 @@ class Manager extends PublicEmitter implements IGroupManager { /** @var \OC\SubAdmin */ private $subAdmin = null; + private DisplayNameCache $displayNameCache; + public function __construct(\OC\User\Manager $userManager, EventDispatcherInterface $dispatcher, - LoggerInterface $logger) { + LoggerInterface $logger, + ICacheFactory $cacheFactory) { $this->userManager = $userManager; $this->dispatcher = $dispatcher; $this->logger = $logger; + $this->displayNameCache = new DisplayNameCache($cacheFactory, $this); $cachedGroups = &$this->cachedGroups; $cachedUserGroups = &$this->cachedUserGroups; @@ -338,6 +343,14 @@ class Manager extends PublicEmitter implements IGroupManager { return $this->cachedUserGroups[$uid]; } + /** + * @param string $groupId + * @return ?string + */ + public function getDisplayName(string $groupId): ?string { + return $this->displayNameCache->getDisplayName($groupId); + } + /** * get an array of groupid and displayName for a user * @@ -346,7 +359,7 @@ class Manager extends PublicEmitter implements IGroupManager { */ public function getUserGroupNames(IUser $user) { return array_map(function ($group) { - return ['displayName' => $group->getDisplayName()]; + return ['displayName' => $this->displayNameCache->getDisplayName($group->getGID())]; }, $this->getUserGroups($user)); } diff --git a/lib/private/Server.php b/lib/private/Server.php index 39bfc08dafd..07e90843a98 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -487,7 +487,8 @@ class Server extends ServerContainer implements IServerContainer { $groupManager = new \OC\Group\Manager( $this->get(IUserManager::class), $c->get(SymfonyAdapter::class), - $this->get(LoggerInterface::class) + $this->get(LoggerInterface::class), + $this->get(ICacheFactory::class) ); $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { /** @var IEventDispatcher $dispatcher */ diff --git a/lib/public/Group/Events/GroupChangedEvent.php b/lib/public/Group/Events/GroupChangedEvent.php new file mode 100644 index 00000000000..9cb5007a916 --- /dev/null +++ b/lib/public/Group/Events/GroupChangedEvent.php @@ -0,0 +1,94 @@ + + * + * @author Anna Larch + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; + +/** + * @since 26.0.0 + */ +class GroupChangedEvent extends Event { + private IGroup $group; + private string $feature; + /** @var mixed */ + private $value; + /** @var mixed */ + private $oldValue; + + /** + * @since 26.0.0 + */ + public function __construct(IGroup $group, + string $feature, + $value, + $oldValue = null) { + parent::__construct(); + $this->group = $group; + $this->feature = $feature; + $this->value = $value; + $this->oldValue = $oldValue; + } + + /** + * + * @since 26.0.0 + * + * @return IGroup + */ + public function getGroup(): IGroup { + return $this->group; + } + + /** + * + * @since 26.0.0 + * + * @return string + */ + public function getFeature(): string { + return $this->feature; + } + + /** + * @since 26.0.0 + * + * @return mixed + */ + public function getValue() { + return $this->value; + } + + /** + * + * @since 26.0.0 + * + * @return mixed + */ + public function getOldValue() { + return $this->oldValue; + } +} diff --git a/lib/public/IGroupManager.php b/lib/public/IGroupManager.php index d942caac9b4..2e2685eeeb4 100644 --- a/lib/public/IGroupManager.php +++ b/lib/public/IGroupManager.php @@ -145,4 +145,14 @@ interface IGroupManager { * @since 8.0.0 */ public function isInGroup($userId, $group); + + /** + * Get the display name of a Nextcloud group + * + * @param string $groupId + * @return ?string display name, if any + * + * @since 26.0.0 + */ + public function getDisplayName(string $groupId): ?string; } diff --git a/tests/lib/Group/ManagerTest.php b/tests/lib/Group/ManagerTest.php index d689fd4eb7a..65210bcc0f7 100644 --- a/tests/lib/Group/ManagerTest.php +++ b/tests/lib/Group/ManagerTest.php @@ -26,6 +26,7 @@ namespace Test\Group; use OC\Group\Database; use OC\User\Manager; use OCP\GroupInterface; +use OCP\ICacheFactory; use OCP\IUser; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; @@ -39,6 +40,8 @@ class ManagerTest extends TestCase { protected $dispatcher; /** @var LoggerInterface|MockObject */ protected $logger; + /** @var ICacheFactory|MockObject */ + private $cache; protected function setUp(): void { parent::setUp(); @@ -46,6 +49,7 @@ class ManagerTest extends TestCase { $this->userManager = $this->createMock(Manager::class); $this->dispatcher = $this->createMock(EventDispatcherInterface::class); $this->logger = $this->createMock(LoggerInterface::class); + $this->cache = $this->createMock(ICacheFactory::class); } private function getTestUser($userId) { @@ -107,7 +111,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $group = $manager->get('group1'); @@ -116,7 +120,7 @@ class ManagerTest extends TestCase { } public function testGetNoBackend() { - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $this->assertNull($manager->get('group1')); } @@ -131,7 +135,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(false); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $this->assertNull($manager->get('group1')); @@ -141,7 +145,7 @@ class ManagerTest extends TestCase { $backend = new \Test\Util\Group\Dummy(); $backend->createGroup('group1'); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $group = $manager->get('group1'); @@ -168,7 +172,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend1); $manager->addBackend($backend2); @@ -194,7 +198,7 @@ class ManagerTest extends TestCase { return true; }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $group = $manager->createGroup('group1'); @@ -223,7 +227,7 @@ class ManagerTest extends TestCase { ->method('getGroupDetails') ->willReturn([]); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $group = $manager->createGroup('group1'); @@ -240,7 +244,7 @@ class ManagerTest extends TestCase { $backend->expects($this->never()) ->method('createGroup'); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $group = $manager->createGroup('group1'); @@ -261,7 +265,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $groups = $manager->search('1'); @@ -295,7 +299,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend1); $manager->addBackend($backend2); @@ -332,7 +336,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend1); $manager->addBackend($backend2); @@ -359,7 +363,7 @@ class ManagerTest extends TestCase { /** @var \OC\User\Manager $userManager */ $userManager = $this->createMock(Manager::class); - $manager = new \OC\Group\Manager($userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $groups = $manager->search('1'); @@ -380,7 +384,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $groups = $manager->getUserGroups($this->getTestUser('user1')); @@ -398,7 +402,7 @@ class ManagerTest extends TestCase { ->with('myUID') ->willReturn(['123', 'abc']); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); /** @var \OC\User\User|\PHPUnit\Framework\MockObject\MockObject $user */ @@ -428,7 +432,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(false); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); /** @var \OC\User\User|\PHPUnit\Framework\MockObject\MockObject $user */ @@ -454,7 +458,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $this->assertTrue($manager->isInGroup('user1', 'group1')); @@ -473,7 +477,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $this->assertTrue($manager->isAdmin('user1')); @@ -492,7 +496,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $this->assertFalse($manager->isAdmin('user1')); @@ -523,7 +527,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend1); $manager->addBackend($backend2); @@ -582,7 +586,7 @@ class ManagerTest extends TestCase { } }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', 'user3'); @@ -642,7 +646,7 @@ class ManagerTest extends TestCase { } }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', 'user3', 1); @@ -706,7 +710,7 @@ class ManagerTest extends TestCase { } }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', 'user3', 1, 1); @@ -746,7 +750,7 @@ class ManagerTest extends TestCase { } }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', ''); @@ -785,7 +789,7 @@ class ManagerTest extends TestCase { } }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', '', 1); @@ -824,7 +828,7 @@ class ManagerTest extends TestCase { } }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', '', 1, 1); @@ -852,7 +856,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); // prime cache @@ -895,7 +899,7 @@ class ManagerTest extends TestCase { ->method('removeFromGroup') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); // prime cache @@ -925,7 +929,7 @@ class ManagerTest extends TestCase { ->with('user1') ->willReturn(null); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $groups = $manager->getUserIdGroups('user1'); @@ -951,7 +955,7 @@ class ManagerTest extends TestCase { ['group2', ['gid' => 'group2']], ]); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); // group with display name