Skip to content

Commit c0cab68

Browse files
authored
Merge pull request #59388 from nextcloud/fix/noid/files-search-default-limit
fix(file-search): use default limit to search query if not provided on request body
2 parents 1a2d36a + 3539476 commit c0cab68

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

apps/dav/lib/Files/FileSearchBackend.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ private function transformQuery(Query $query, ?SearchBinaryOperator $scopeOperat
343343
}, $query->orderBy);
344344

345345
$limit = $query->limit;
346+
$maxResults = $limit->maxResults !== 0 ? (int)$limit->maxResults : 100;
346347
$offset = $limit->firstResult;
347348

348349
$limitHome = false;
@@ -370,7 +371,7 @@ private function transformQuery(Query $query, ?SearchBinaryOperator $scopeOperat
370371

371372
return new SearchQuery(
372373
$operators,
373-
(int)$limit->maxResults,
374+
$maxResults,
374375
$offset,
375376
$orders,
376377
$this->user,

apps/dav/tests/unit/Files/FileSearchBackendTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function testSearchFilename(): void {
9797
'name',
9898
'foo'
9999
),
100-
0,
100+
100,
101101
0,
102102
[],
103103
$this->user
@@ -126,7 +126,7 @@ public function testSearchMimetype(): void {
126126
'mimetype',
127127
'foo'
128128
),
129-
0,
129+
100,
130130
0,
131131
[],
132132
$this->user
@@ -155,7 +155,7 @@ public function testSearchSize(): void {
155155
'size',
156156
10
157157
),
158-
0,
158+
100,
159159
0,
160160
[],
161161
$this->user
@@ -184,7 +184,7 @@ public function testSearchMtime(): void {
184184
'mtime',
185185
10
186186
),
187-
0,
187+
100,
188188
0,
189189
[],
190190
$this->user
@@ -213,7 +213,7 @@ public function testSearchIsCollection(): void {
213213
'mimetype',
214214
FileInfo::MIMETYPE_FOLDER
215215
),
216-
0,
216+
100,
217217
0,
218218
[],
219219
$this->user

0 commit comments

Comments
 (0)