diff --git a/lib/private/Group/Database.php b/lib/private/Group/Database.php index 569cfa5007f34..ef5641d81370d 100644 --- a/lib/private/Group/Database.php +++ b/lib/private/Group/Database.php @@ -266,7 +266,7 @@ public function getUserGroups($uid) { * * Returns a list with all groups */ - public function getGroups($search = '', $limit = null, $offset = null) { + public function getGroups(string $search = '', int $limit = -1, int $offset = 0) { $this->fixDI(); $query = $this->dbConn->getQueryBuilder(); @@ -283,8 +283,12 @@ public function getGroups($search = '', $limit = null, $offset = null) { ))); } - $query->setMaxResults($limit) - ->setFirstResult($offset); + if ($limit > 0) { + $query->setMaxResults($limit); + } + if ($offset > 0) { + $query->setFirstResult($offset); + } $result = $query->execute(); $groups = []; diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index b718afa516828..0672e519e3668 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -236,14 +236,14 @@ public function createGroup($gid) { /** * @param string $search - * @param int $limit - * @param int $offset + * @param ?int $limit + * @param ?int $offset * @return \OC\Group\Group[] */ - public function search($search, $limit = null, $offset = null) { + public function search(string $search, ?int $limit = null, ?int $offset = 0) { $groups = []; foreach ($this->backends as $backend) { - $groupIds = $backend->getGroups($search, $limit, $offset); + $groupIds = $backend->getGroups($search, $limit ?? -1, $offset ?? 0); foreach ($groupIds as $groupId) { $aGroup = $this->get($groupId); if ($aGroup instanceof IGroup) { diff --git a/lib/public/GroupInterface.php b/lib/public/GroupInterface.php index 56863100c0504..a18d38df0022e 100644 --- a/lib/public/GroupInterface.php +++ b/lib/public/GroupInterface.php @@ -95,7 +95,7 @@ public function getUserGroups($uid); * * Returns a list with all groups */ - public function getGroups($search = '', $limit = -1, $offset = 0); + public function getGroups(string $search = '', int $limit = -1, int $offset = 0); /** * check if a group exists diff --git a/lib/public/IGroupManager.php b/lib/public/IGroupManager.php index 2e2685eeeb4ef..a6655292398b0 100644 --- a/lib/public/IGroupManager.php +++ b/lib/public/IGroupManager.php @@ -96,12 +96,12 @@ public function createGroup($gid); /** * @param string $search - * @param int $limit - * @param int $offset + * @param ?int $limit + * @param ?int $offset * @return \OCP\IGroup[] * @since 8.0.0 */ - public function search($search, $limit = null, $offset = null); + public function search(string $search, ?int $limit = null, ?int $offset = 0); /** * @param \OCP\IUser|null $user