From 2cc2e1321810853817252ea1a83e9e658a2078f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 22 Dec 2022 12:19:06 +0100 Subject: [PATCH] Let OC\Group\Group handle the fallback and remove default implementation from ABackend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/user_ldap/lib/Group_LDAP.php | 13 ++----------- build/psalm-baseline-ocp.xml | 5 ----- lib/public/Group/Backend/ABackend.php | 14 -------------- 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php index ca3a6d13e8fa4..fac7109366531 100644 --- a/apps/user_ldap/lib/Group_LDAP.php +++ b/apps/user_ldap/lib/Group_LDAP.php @@ -48,12 +48,11 @@ use OC\ServerNotAvailableException; use OCP\Cache\CappedMemoryCache; use OCP\GroupInterface; -use OCP\Group\Backend\ABackend; use OCP\Group\Backend\IDeleteGroupBackend; use OCP\Group\Backend\IGetDisplayNameBackend; use Psr\Log\LoggerInterface; -class Group_LDAP extends ABackend implements GroupInterface, IGroupLDAP, IGetDisplayNameBackend, IDeleteGroupBackend { +class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, IGetDisplayNameBackend, IDeleteGroupBackend { protected bool $enabled = false; /** @var CappedMemoryCache $cachedGroupMembers array of users with gid as key */ @@ -64,7 +63,6 @@ class Group_LDAP extends ABackend implements GroupInterface, IGroupLDAP, IGetDis protected CappedMemoryCache $cachedNestedGroups; protected GroupPluginManager $groupPluginManager; protected LoggerInterface $logger; - protected Access $access; /** * @var string $ldapGroupMemberAssocAttr contains the LDAP setting (in lower case) with the same name @@ -72,7 +70,7 @@ class Group_LDAP extends ABackend implements GroupInterface, IGroupLDAP, IGetDis protected string $ldapGroupMemberAssocAttr; public function __construct(Access $access, GroupPluginManager $groupPluginManager) { - $this->access = $access; + parent::__construct($access); $filter = $this->access->connection->ldapGroupFilter; $gAssoc = $this->access->connection->ldapGroupMemberAssocAttr; if (!empty($filter) && !empty($gAssoc)) { @@ -1333,11 +1331,4 @@ public function getDisplayName(string $gid): string { $this->access->connection->writeToCache($cacheKey, $displayName); return $displayName; } - - public function searchInGroup(string $gid, string $search = '', int $limit = -1, int $offset = 0): array { - if (!$this->enabled) { - return []; - } - return parent::searchInGroup($gid, $search, $limit, $offset); - } } diff --git a/build/psalm-baseline-ocp.xml b/build/psalm-baseline-ocp.xml index fc56126c38a2f..208be393e1f93 100644 --- a/build/psalm-baseline-ocp.xml +++ b/build/psalm-baseline-ocp.xml @@ -5,11 +5,6 @@ OC - - - OC - - $this->request->server diff --git a/lib/public/Group/Backend/ABackend.php b/lib/public/Group/Backend/ABackend.php index 53bd7bfbb1961..64884abf52091 100644 --- a/lib/public/Group/Backend/ABackend.php +++ b/lib/public/Group/Backend/ABackend.php @@ -26,15 +26,11 @@ namespace OCP\Group\Backend; use OCP\GroupInterface; -use OCP\IUserManager; -use OCP\Server; -use OC\User\LazyUser; /** * @since 14.0.0 */ abstract class ABackend implements GroupInterface, ISearchableGroupBackend { - /** * @deprecated 14.0.0 * @@ -68,14 +64,4 @@ public function implementsActions($actions): bool { return (bool)($actions & $implements); } - - public function searchInGroup(string $gid, string $search = '', int $limit = -1, int $offset = 0): array { - // Default implementation for compatibility reasons - $userManager = Server::get(IUserManager::class); - $users = []; - foreach ($this->usersInGroup($gid, $search, $limit, $offset) as $userId) { - $users[$userId] = new LazyUser($userId, $userManager); - } - return $users; - } }