Skip to content

Commit ae31d03

Browse files
authored
Merge pull request #41486 from nextcloud/fix/41470/invalid_user_group
Fix invalid users/groups handling in advanced search
2 parents 0d4ece5 + 33837e7 commit ae31d03

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

core/Controller/UnifiedSearchController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*/
2929
namespace OC\Core\Controller;
3030

31+
use InvalidArgumentException;
3132
use OC\Search\SearchComposer;
3233
use OC\Search\SearchQuery;
3334
use OCA\Core\ResponseDefinitions;
@@ -111,7 +112,7 @@ public function search(
111112

112113
try {
113114
$filters = $this->composer->buildFilterList($providerId, $this->request->getParams());
114-
} catch (UnsupportedFilter $e) {
115+
} catch (UnsupportedFilter|InvalidArgumentException $e) {
115116
return new DataResponse($e->getMessage(), Http::STATUS_BAD_REQUEST);
116117
}
117118
return new DataResponse(

lib/private/Search/Filter/GroupFilter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ public function __construct(
3838
string $value,
3939
IGroupManager $groupManager,
4040
) {
41-
$this->group = $groupManager->get($value);
42-
if ($this->group === null) {
41+
$group = $groupManager->get($value);
42+
if ($group === null) {
4343
throw new InvalidArgumentException('Group '.$value.' not found');
4444
}
45+
$this->group = $group;
4546
}
4647

4748
public function get(): IGroup {

lib/private/Search/Filter/UserFilter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ public function __construct(
3838
string $value,
3939
IUserManager $userManager,
4040
) {
41-
$this->user = $userManager->get($value);
42-
if ($this->user === null) {
41+
$user = $userManager->get($value);
42+
if ($user === null) {
4343
throw new InvalidArgumentException('User '.$value.' not found');
4444
}
45+
$this->user = $user;
4546
}
4647

4748
public function get(): IUser {

0 commit comments

Comments
 (0)