Browse Source

CacheJail should apply limit and offset after searching

Else the results might not be correct.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
tags/v14.0.0beta1
Roeland Jago Douma 6 years ago
parent
commit
c1ff12e234
No account linked to committer's email address

+ 1
- 1
apps/dav/lib/Files/FileSearchBackend.php View File

@@ -271,7 +271,7 @@ class FileSearchBackend implements ISearchBackend {
// TODO offset
$limit = $query->limit;
$orders = array_map([$this, 'mapSearchOrder'], $query->orderBy);
return new SearchQuery($this->transformSearchOperation($query->where), $limit->maxResults, 0, $orders, $this->user);
return new SearchQuery($this->transformSearchOperation($query->where), (int)$limit->maxResults, 0, $orders, $this->user);
}

/**

+ 9
- 2
lib/private/Files/Cache/Wrapper/CacheJail.php View File

@@ -29,6 +29,7 @@
namespace OC\Files\Cache\Wrapper;

use OC\Files\Cache\Cache;
use OC\Files\Search\SearchQuery;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Search\ISearchQuery;

@@ -236,8 +237,14 @@ class CacheJail extends CacheWrapper {
}

public function searchQuery(ISearchQuery $query) {
$results = $this->getCache()->searchQuery($query);
return $this->formatSearchResults($results);
$simpleQuery = new SearchQuery($query->getSearchOperation(), 0, 0, $query->getOrder(), $query->getUser());
$results = $this->getCache()->searchQuery($simpleQuery);
$results = $this->formatSearchResults($results);

$limit = $query->getLimit() === 0 ? NULL : $query->getLimit();
$results = array_slice($results, $query->getOffset(), $limit);

return $results;
}

/**

Loading…
Cancel
Save