summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Group/Database.php10
-rw-r--r--lib/private/Group/Manager.php8
-rw-r--r--lib/public/GroupInterface.php2
-rw-r--r--lib/public/IGroupManager.php6
4 files changed, 15 insertions, 11 deletions
diff --git a/lib/private/Group/Database.php b/lib/private/Group/Database.php
index 569cfa5007f..ef5641d8137 100644
--- a/lib/private/Group/Database.php
+++ b/lib/private/Group/Database.php
@@ -266,7 +266,7 @@ class Database extends ABackend implements
*
* 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 @@ class Database extends ABackend implements
)));
}
- $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 b718afa5168..0672e519e36 100644
--- a/lib/private/Group/Manager.php
+++ b/lib/private/Group/Manager.php
@@ -236,14 +236,14 @@ class Manager extends PublicEmitter implements IGroupManager {
/**
* @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 56863100c05..a18d38df002 100644
--- a/lib/public/GroupInterface.php
+++ b/lib/public/GroupInterface.php
@@ -95,7 +95,7 @@ interface GroupInterface {
*
* 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 2e2685eeeb4..a6655292398 100644
--- a/lib/public/IGroupManager.php
+++ b/lib/public/IGroupManager.php
@@ -96,12 +96,12 @@ interface IGroupManager {
/**
* @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