Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/private/Group/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 = [];
Expand Down
8 changes: 4 additions & 4 deletions lib/private/Group/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/public/GroupInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/public/IGroupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down