Skip to content
This repository
Browse code

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

…so limit() and sort() are applied correctly
  • Loading branch information...
commit 8b834877f9254c93a2bd6055dda04ce9f76f7a4f 1 parent b04c199
Sean Harvey authored June 15, 2012

Showing 1 changed file with 16 additions and 14 deletions. Show diff stats Hide diff stats

  1. 30  search/SearchContext.php
30  search/SearchContext.php
@@ -115,20 +115,22 @@ protected function applyBaseTableFields() {
115 115
 	 * @return DataList
116 116
 	 */
117 117
 	public function getQuery($searchParams, $sort = false, $limit = false, $existingQuery = null) {
118  
-	    if($existingQuery) {
119  
-	        if(!($existingQuery instanceof DataList)) throw new InvalidArgumentException("existingQuery must be DataList");
120  
-	        if($existingQuery->dataClass() != $this->modelClass) throw new InvalidArgumentException("existingQuery's dataClass is " . $existingQuery->dataClass() . ", $this->modelClass expected.");
121  
-	        $query = $existingQuery;
122  
-	         
123  
-	    } else {
124  
-	        $query = DataList::create($this->modelClass);
125  
-        }
126  
-        
127  
-		if(is_array($limit)) $query->limit(isset($limit['limit']) ? $limit['limit'] : null, isset($limit['start']) ? $limit['start'] : null);
128  
-		else $query->limit($limit);
129  
-		
130  
-		$query->sort($sort);
131  
-		
  118
+		if($existingQuery) {
  119
+			if(!($existingQuery instanceof DataList)) throw new InvalidArgumentException("existingQuery must be DataList");
  120
+			if($existingQuery->dataClass() != $this->modelClass) throw new InvalidArgumentException("existingQuery's dataClass is " . $existingQuery->dataClass() . ", $this->modelClass expected.");
  121
+			$query = $existingQuery;
  122
+		} else {
  123
+			$query = DataList::create($this->modelClass);
  124
+		}
  125
+
  126
+		if(is_array($limit)) {
  127
+			$query = $query->limit(isset($limit['limit']) ? $limit['limit'] : null, isset($limit['start']) ? $limit['start'] : null);
  128
+		} else {
  129
+			$query = $query->limit($limit);
  130
+		}
  131
+
  132
+		$query = $query->sort($sort);
  133
+
132 134
 		// hack to work with $searchParems when it's an Object 
133 135
 		$searchParamArray = array();
134 136
 		if (is_object($searchParams)) {

0 notes on commit 8b83487

Please sign in to comment.
Something went wrong with that request. Please try again.