Skip to content

Commit

Permalink
Let OC\Group\Group handle the fallback and remove default implementat…
Browse files Browse the repository at this point in the history
…ion from ABackend

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Dec 22, 2022
1 parent fc4212d commit 2cc2e13
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 30 deletions.
13 changes: 2 additions & 11 deletions apps/user_ldap/lib/Group_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string[]> $cachedGroupMembers array of users with gid as key */
Expand All @@ -64,15 +63,14 @@ 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
*/
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)) {
Expand Down Expand Up @@ -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);
}
}
5 changes: 0 additions & 5 deletions build/psalm-baseline-ocp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
14 changes: 0 additions & 14 deletions lib/public/Group/Backend/ABackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 2cc2e13

Please sign in to comment.