]> source.dussan.org Git - nextcloud-server.git/commitdiff
Let OC\Group\Group handle the fallback and remove default implementation from ABackend
authorCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 22 Dec 2022 11:19:06 +0000 (12:19 +0100)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 27 Apr 2023 10:00:43 +0000 (12:00 +0200)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/user_ldap/lib/Group_LDAP.php
build/psalm-baseline-ocp.xml
lib/public/Group/Backend/ABackend.php

index ca3a6d13e8fa44fa8a4517495a071693b80fecd4..fac71093665318444573ae9fed41473c0053df33 100644 (file)
@@ -48,12 +48,11 @@ use Exception;
 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<string[]> $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 @@ class Group_LDAP extends ABackend implements GroupInterface, IGroupLDAP, IGetDis
                $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);
-       }
 }
index 1613a6fe8fab9d658c2fccf245d8a2b9c2f97281..e993e85e5a247611a9597dcf87f87191aebf38d3 100644 (file)
@@ -5,11 +5,6 @@
       <code>OC</code>
     </UndefinedClass>
   </file>
-  <file src="lib/public/Group/Backend/ABackend.php">
-    <UndefinedClass occurrences="2">
-      <code>OC</code>
-    </UndefinedClass>
-  </file>
   <file src="lib/public/AppFramework/ApiController.php">
     <NoInterfaceProperties occurrences="1">
       <code>$this-&gt;request-&gt;server</code>
index ee1b62c887bd7b2f18bbcc26c780e8f937fa3e87..7f5cf732335f30d65bdf41d5067fbf86287d9ed6 100644 (file)
@@ -26,14 +26,11 @@ declare(strict_types=1);
 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 {
+abstract class ABackend implements GroupInterface {
        /**
         * @deprecated 14.0.0
         * @since 14.0.0
@@ -68,14 +65,4 @@ abstract class ABackend implements GroupInterface, ISearchableGroupBackend {
 
                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;
-       }
 }