From: Greg Sabino Mullane Date: Thu, 5 Apr 2007 13:51:16 +0000 (+0000) Subject: More cleanups of tsearch2 parse query X-Git-Tag: 1.31.0-rc.0~53466 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/supprimer.php?a=commitdiff_plain;h=e7f2cb7f7b5f164632a2c6724610a6dbfed8a758;p=lhc%2Fweb%2Fwiklou.git More cleanups of tsearch2 parse query --- diff --git a/includes/SearchPostgres.php b/includes/SearchPostgres.php index 3562b3cbf4..daebfa7130 100644 --- a/includes/SearchPostgres.php +++ b/includes/SearchPostgres.php @@ -61,6 +61,9 @@ class SearchPostgres extends SearchEngine { $term = preg_replace('/\s*\(\s*/', ' (', $term); $term = preg_replace('/\s*\)\s*/', ') ', $term); + ## Treat colons as word separators: + $term = preg_replace('/:/', ' ', $term); + $this->searchTerms = array(); $m = array(); $searchstring = ''; @@ -92,6 +95,12 @@ class SearchPostgres extends SearchEngine { ## Remove any doubled-up operators $searchstring = preg_replace('/([\!\&\|]) +(?:[\&\|] +)+/', "$1 ", $searchstring); + ## Remove any non-spaced operators (e.g. "Zounds!") + $searchstring = preg_replace('/([^ ])[\!\&\|]/', "$1", $searchstring); + + ## Remove any trailing operators + $searchstring = preg_replace('/(?: [\!\&\|])*$/', '', $searchstring); + ## Quote the whole thing $searchstring = $this->db->addQuotes($searchstring);