]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add group display name cache 34941/head
authorAnna Larch <anna@nextcloud.com>
Thu, 3 Nov 2022 11:51:29 +0000 (12:51 +0100)
committerAnna (Rebase PR Action) <miaulalala@users.noreply.github.com>
Mon, 28 Nov 2022 11:52:55 +0000 (11:52 +0000)
Signed-off-by: Anna Larch <anna@nextcloud.com>
apps/files_sharing/lib/AppInfo/Application.php
lib/composer/composer/autoload_classmap.php
lib/composer/composer/autoload_static.php
lib/private/Group/DisplayNameCache.php [new file with mode: 0644]
lib/private/Group/Group.php
lib/private/Group/Manager.php
lib/private/Server.php
lib/public/Group/Events/GroupChangedEvent.php [new file with mode: 0644]
lib/public/IGroupManager.php
tests/lib/Group/ManagerTest.php

index 63fdced90111bc15119222a9e02a704287fcdaf8..960d376c6d3485bdfc2123fef0105dbdeeef38ec 100644 (file)
@@ -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 {
index d8016e10b79922cd4f5d15874a8d98b81428673a..90e7fe51fa74aa8aacf00327e2b2ee6b832948c1 100644 (file)
@@ -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',
index 595c7ec3736d9e9aaffd1ffb40a70f1b367e0382..8cef29efc39bcb2c5a3929db70a6b384d4d0b0f6 100644 (file)
@@ -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 (file)
index 0000000..d724b6c
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright 2022 Anna Larch <anna.larch@gmx.net>
+ * @author Anna Larch <anna.larch@gmx.net>
+ *
+ * @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 <http://www.gnu.org/licenses/>
+ *
+ */
+
+
+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
+               }
+       }
+}
index 2ef4d2ee23fd3888c2598fac307e03aec2a01414..ae70a611e4e1d283c5141ea14aa9dd8708c62168 100644 (file)
@@ -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;
                                }
                        }
index 28f7a400b41dd0f063fcd8050e0eaf4303ac318a..b718afa516828c88bbd0d693ff732c55cb360984 100644 (file)
@@ -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));
        }
 
index 39bfc08dafde36b87cf277059a3bd1b769b8298f..07e90843a980399ea7857345bd6459573f5e134c 100644 (file)
@@ -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 (file)
index 0000000..9cb5007
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright 2022 Anna Larch <anna.larch@gmx.net>
+ *
+ * @author Anna Larch <anna.larch@gmx.net>
+ *
+ * @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 <http://www.gnu.org/licenses/>.
+ *
+ */
+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;
+       }
+}
index d942caac9b48d5f385545faa12650143ea383840..2e2685eeeb4efae60e151e47e61368967ead88a1 100644 (file)
@@ -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;
 }
index d689fd4eb7a49f48b85c3b5832054afe650abd28..65210bcc0f782364a5c86e917132a74494154e52 100644 (file)
@@ -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