diff options
author | Andreas Gohr <andi@splitbrain.org> | 2007-08-04 10:12:26 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2007-08-04 10:12:26 +0200 |
commit | a21136cd1c468d48e0fd387adbde0de5fe48b402 (patch) | |
tree | 07f551150312a260cf10f84269afb51081570122 | |
parent | c97dfb07cefa8287f778773c12a19108c079cb6b (diff) | |
download | rpg-a21136cd1c468d48e0fd387adbde0de5fe48b402.tar.gz rpg-a21136cd1c468d48e0fd387adbde0de5fe48b402.tar.bz2 |
fulltext search fixes FS#1191 FS#1192
darcs-hash:20070804081226-7ad00-a8e7127c7122a96f9817158d87e1a364d8cdbc9f.gz
-rw-r--r-- | inc/fulltext.php | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/inc/fulltext.php b/inc/fulltext.php index f7a9320c9..59a469362 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -78,12 +78,14 @@ function ft_pageSearch($query,&$poswords){ //build a regexp $q['phrases'] = array_map('utf8_strtolower',$q['phrases']); $q['phrases'] = array_map('ft_preg_quote_cb',$q['phrases']); - $regex = '('.join('|',$q['phrases']).')'; // check the source of all documents for the exact phrases foreach(array_keys($docs) as $id){ $text = utf8_strtolower(rawWiki($id)); - if(!preg_match('/'.$regex.'/usi',$text)){ - unset($docs[$id]); // no hit - remove + foreach($q['phrases'] as $phrase){ + if(!preg_match('/'.$phrase.'/usi',$text)){ + unset($docs[$id]); // no hit - remove + break; + } } } } @@ -280,14 +282,14 @@ function ft_resultCombine($args){ $result = array(); if ($array_count > 1) { - foreach ($args[0] as $key1 => $value1) { + foreach ($args[0] as $key => $value) { + $result[$key] = $value; for ($i = 1; $i !== $array_count; $i++) { - foreach ($args[$i] as $key2 => $value2) { - if ((string) $key1 === (string) $key2) { - if(!isset($result[$key1])) $result[$key1] = $value1; - $result[$key1] += $value2; - } + if (!isset($args[$i][$key])) { + unset($result[$key]); + break; } + $result[$key] += $args[$i][$key]; } } } |