fusionforge (5.1.1-2) common/search/ExportProjectSearchQuery.class.php

Summary

 common/search/ExportProjectSearchQuery.class.php |   70 +++++++----------------
 1 file changed, 23 insertions(+), 47 deletions(-)

    
download this patch

Patch contents

--- fusionforge-5.1.1.orig/common/search/ExportProjectSearchQuery.class.php
+++ fusionforge-5.1.1/common/search/ExportProjectSearchQuery.class.php
@@ -45,59 +45,35 @@
 
 		$qpa = db_construct_qpa () ;
 		if (forge_get_config('use_fti')) {
-			$words = $this->getFormattedWords();
-			if(count($this->words)) {
-				$qpa = db_construct_qpa ($qpa,
-							 'SELECT ts_headline(unix_group_name, q) as unix_group_name, ts_headline(short_description, q) as short_description, type_id, groups.group_id, license, register_time FROM groups, groups_idx, to_tsquery($1) q ',
-							 array (implode (' ', $words))) ;
-				$qpa = db_construct_qpa ($qpa,
-							 'WHERE status IN ($1, $2) AND short_description <> $3 AND groups.group_id = groups_idx.group_id',
-							 array ('A',
-								'H',
-								'')) ;
+			$words = $this->getFTIwords();
+
+			$qpa = db_construct_qpa ($qpa,
+						 'SELECT ts_headline(unix_group_name, q) as unix_group_name, ts_headline(short_description, q) as short_description, type_id, groups.group_id, license, register_time FROM groups, groups_idx, to_tsquery($1) q ',
+						 array (implode (' ', $words))) ;
+			$qpa = db_construct_qpa ($qpa,
+						 'WHERE status IN ($1, $2) AND short_description <> $3 AND groups.group_id = groups_idx.group_id',
+						 array ('A',
+							'H',
+							'')) ;
+			$qpa = db_construct_qpa ($qpa,
+						 ' AND (vectors @@ q' ) ;
+			if (count($this->phrases)) {
 				$qpa = db_construct_qpa ($qpa,
-							 ' AND (vectors @@ q' ) ;
-				if (count($this->phrases)) {
-					$qpa = db_construct_qpa ($qpa,
-								 $this->getOperator()) ;
-					$qpa = db_construct_qpa ($qpa,
-								 '(') ;
-					$qpa = $this->addMatchCondition($qpa, 'group_name');
-					$qpa = db_construct_qpa ($qpa,
-								 ') OR (') ;
-					$qpa = $this->addMatchCondition($qpa, 'unix_group_name');
-					$qpa = db_construct_qpa ($qpa,
-								 ') OR (') ;
-					$qpa = $this->addMatchCondition($qpa, 'short_description');
-					$qpa = db_construct_qpa ($qpa,
-								 ')') ;
-				}
+							 $this->getOperator()) ;
 				$qpa = db_construct_qpa ($qpa,
-							 ') ORDER BY ts_rank(vectors, q) DESC, group_name ASC') ;
-			} else {
+							 '(') ;
+				$qpa = $this->addMatchCondition($qpa, 'group_name');
 				$qpa = db_construct_qpa ($qpa,
-							 'SELECT unix_group_name, short_description, type_id, groups.group_id, license, register_time FROM groups ') ;
+							 ') OR (') ;
+				$qpa = $this->addMatchCondition($qpa, 'unix_group_name');
 				$qpa = db_construct_qpa ($qpa,
-							 'WHERE status IN ($1, $2) AND short_description <> $3',
-							 array ('A',
-								'H',
-								'')) ;
-				if (count($this->phrases)) {
-					$qpa = db_construct_qpa ($qpa,
-								 ' AND ((' ) ;
-					$qpa = $this->addMatchCondition($qpa, 'group_name');
-					$qpa = db_construct_qpa ($qpa,
-								 ') OR (') ;
-					$qpa = $this->addMatchCondition($qpa, 'unix_group_name');
-					$qpa = db_construct_qpa ($qpa,
-								 ') OR (') ;
-					$qpa = $this->addMatchCondition($qpa, 'short_description');
-					$qpa = db_construct_qpa ($qpa,
-								 '))') ;
-				}
+							 ') OR (') ;
+				$qpa = $this->addMatchCondition($qpa, 'short_description');
 				$qpa = db_construct_qpa ($qpa,
-							 ') ORDER BY group_name' ) ;
+							 ')') ;
 			}
+			$qpa = db_construct_qpa ($qpa,
+						 ') ORDER BY ts_rank(vectors, q) DESC, group_name ASC') ;
 		} else {
 			$qpa = db_construct_qpa ($qpa,
 						 'SELECT group_name,unix_group_name,type_id,groups.group_id, short_description,license,register_time FROM groups WHERE status IN ($1, $2) AND short_description <> $3 AND groups.group_id = groups_idx.group_id',