CacheJail should apply limit and offset after searching

Else the results might not be correct.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-02-07 09:35:55 +01:00
parent 6b5419ddf0
commit c1ff12e234
No known key found for this signature in database
GPG Key ID: F941078878347C0C
2 changed files with 10 additions and 3 deletions

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);
}
/**

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;
}
/**