Skip to content

Commit

Permalink
fixup! fixup! Fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlSchwan committed May 13, 2022
1 parent 5eae494 commit 01190a9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 16 deletions.
6 changes: 1 addition & 5 deletions apps/user_ldap/lib/GroupPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,7 @@ public function countUsersInGroup(string $gid, string $search = ''): int {
$plugin = $this->which[GroupInterface::COUNT_USERS];

if ($plugin) {
$count = $plugin->countUsersInGroup($gid,$search);
if ($count === false) {
return 0; // no entry found
}
return $count;
return (int)$plugin->countUsersInGroup($gid, $search);
}
throw new \Exception('No plugin implements countUsersInGroup in this LDAP Backend.');
}
Expand Down
4 changes: 2 additions & 2 deletions apps/user_ldap/lib/Group_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -1028,15 +1028,15 @@ public function countUsersInGroup(string $gid, string $search = ''): int {
$groupDN = $this->access->groupname2dn($gid);
if (!$groupDN) {
// group couldn't be found, return empty result set
$this->access->connection->writeToCache($cacheKey, false);
$this->access->connection->writeToCache($cacheKey, 0);
return 0;
}

$members = $this->_groupMembers($groupDN);
$primaryUserCount = $this->countUsersInPrimaryGroup($groupDN, '');
if (!$members && $primaryUserCount === 0) {
//in case users could not be retrieved, return empty result set
$this->access->connection->writeToCache($cacheKey, false);
$this->access->connection->writeToCache($cacheKey, 0);
return 0;
}

Expand Down
9 changes: 1 addition & 8 deletions apps/user_ldap/lib/Group_Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,6 @@ public function getBackendName(): string {
}

public function searchInGroup(string $gid, string $search = '', int $limit = -1, int $offset = 0): array {
$users = [];

foreach ($this->backends as $backend) {
$backendUsers = $backend->searchInGroup($gid, $search, $limit, $offset);
$users = array_merge($users, $backendUsers);
}

return $users;
return $this->handleRequest($gid, 'searchInGroup', [$gid, $search, $limit, $offset]);
}
}
1 change: 0 additions & 1 deletion tests/lib/Util/Group/Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
use OCP\Group\Backend\IRemoveFromGroupBackend;
use OCP\Group\Backend\ICreateGroupBackend;
use OCP\Group\Backend\ICountUsersBackend;
use OCP\IUser;

/**
* Dummy group backend, does not keep state, only for testing use
Expand Down

0 comments on commit 01190a9

Please sign in to comment.