Преглед изворни кода

Merge pull request #36592 from nextcloud/groupmanager-search-typing

fix default values and type hints for GroupManager::search
tags/v27.0.0beta2
Robin Appelman пре 1 година
родитељ
комит
1f4dd62b4e
No account linked to committer's email address

+ 7
- 3
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 = [];

+ 4
- 4
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) {

+ 1
- 1
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

+ 3
- 3
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

Loading…
Откажи
Сачувај