mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX DataList used in SearchContext::getQuery() should be returned so limit() and sort() are applied correctly
This commit is contained in:
parent
b04c199064
commit
8b834877f9
@ -115,20 +115,22 @@ class SearchContext extends Object {
|
||||
* @return DataList
|
||||
*/
|
||||
public function getQuery($searchParams, $sort = false, $limit = false, $existingQuery = null) {
|
||||
if($existingQuery) {
|
||||
if(!($existingQuery instanceof DataList)) throw new InvalidArgumentException("existingQuery must be DataList");
|
||||
if($existingQuery->dataClass() != $this->modelClass) throw new InvalidArgumentException("existingQuery's dataClass is " . $existingQuery->dataClass() . ", $this->modelClass expected.");
|
||||
$query = $existingQuery;
|
||||
|
||||
} else {
|
||||
$query = DataList::create($this->modelClass);
|
||||
}
|
||||
|
||||
if(is_array($limit)) $query->limit(isset($limit['limit']) ? $limit['limit'] : null, isset($limit['start']) ? $limit['start'] : null);
|
||||
else $query->limit($limit);
|
||||
|
||||
$query->sort($sort);
|
||||
|
||||
if($existingQuery) {
|
||||
if(!($existingQuery instanceof DataList)) throw new InvalidArgumentException("existingQuery must be DataList");
|
||||
if($existingQuery->dataClass() != $this->modelClass) throw new InvalidArgumentException("existingQuery's dataClass is " . $existingQuery->dataClass() . ", $this->modelClass expected.");
|
||||
$query = $existingQuery;
|
||||
} else {
|
||||
$query = DataList::create($this->modelClass);
|
||||
}
|
||||
|
||||
if(is_array($limit)) {
|
||||
$query = $query->limit(isset($limit['limit']) ? $limit['limit'] : null, isset($limit['start']) ? $limit['start'] : null);
|
||||
} else {
|
||||
$query = $query->limit($limit);
|
||||
}
|
||||
|
||||
$query = $query->sort($sort);
|
||||
|
||||
// hack to work with $searchParems when it's an Object
|
||||
$searchParamArray = array();
|
||||
if (is_object($searchParams)) {
|
||||
|
Loading…
Reference in New Issue
Block a user