From 6db51324fa5ecbd12728b1e86e0d4a7b860a92d4 Mon Sep 17 00:00:00 2001
From: Roeland Jago Douma <roeland@famdouma.nl>
Date: Wed, 2 Oct 2019 09:43:35 +0200
Subject: [PATCH] Fix DB usersInGroups fetching

* Follow the interface defaults
* Only set limit or offset if they are properly set

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
---
 lib/private/Group/Database.php | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/private/Group/Database.php b/lib/private/Group/Database.php
index 7a5728b957d..4df70f143ba 100644
--- a/lib/private/Group/Database.php
+++ b/lib/private/Group/Database.php
@@ -322,7 +322,7 @@ class Database extends ABackend
 	 * @param int $offset
 	 * @return array an array of user ids
 	 */
-	public function usersInGroup($gid, $search = '', $limit = null, $offset = null) {
+	public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
 		$this->fixDI();
 
 		$query = $this->dbConn->getQueryBuilder();
@@ -337,8 +337,13 @@ class Database extends ABackend
 			)));
 		}
 
-		$query->setMaxResults($limit)
-			->setFirstResult($offset);
+		if ($limit !== -1) {
+			$query->setMaxResults($limit);
+		}
+		if ($offset !== 0) {
+			$query->setFirstResult($offset);
+		}
+
 		$result = $query->execute();
 
 		$users = [];
-- 
GitLab