Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUGFIX DataList used in SearchContext::getQuery() should be returned …

…so limit() and sort() are applied correctly
  • Loading branch information...
commit 8b834877f9254c93a2bd6055dda04ce9f76f7a4f 1 parent b04c199
@halkyon halkyon authored
Showing with 16 additions and 14 deletions.
  1. +16 −14 search/SearchContext.php
View
30 search/SearchContext.php
@@ -115,20 +115,22 @@ protected function applyBaseTableFields() {
* @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)) {
Please sign in to comment.
Something went wrong with that request. Please try again.