BUGFIX If full text not enabled, return empty DataObjectSet in MSSQLDatabase::searchEngine() instead of null (undefined variable)

This commit is contained in:
Sean Harvey 2009-10-27 07:08:51 +00:00
parent 3e04b42048
commit e4fe94aae3

View File

@ -1178,7 +1178,11 @@ class MSSQLDatabase extends SS_Database {
* @return object DataObjectSet of result pages * @return object DataObjectSet of result pages
*/ */
public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC", $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false) { public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC", $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false) {
if($this->fullTextEnabled) { $searchResults = new DataObjectSet();
if(!$this->fullTextEnabled) {
return $searchResults;
}
$keywords = Convert::raw2sql(trim($keywords)); $keywords = Convert::raw2sql(trim($keywords));
$htmlEntityKeywords = htmlentities($keywords); $htmlEntityKeywords = htmlentities($keywords);
@ -1229,7 +1233,6 @@ class MSSQLDatabase extends SS_Database {
$query=implode(' UNION ', $tables); $query=implode(' UNION ', $tables);
$result=DB::query($query); $result=DB::query($query);
$searchResults=new DataObjectSet();
foreach($result as $row){ foreach($result as $row){
$row_result=DataObject::get_by_id($row['Source'], $row['ID']); $row_result=DataObject::get_by_id($row['Source'], $row['ID']);
@ -1237,7 +1240,6 @@ class MSSQLDatabase extends SS_Database {
} }
$searchResults->setPageLimits($start, $pageLength, $totalCount); $searchResults->setPageLimits($start, $pageLength, $totalCount);
}
return $searchResults; return $searchResults;
} }