diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-06-16 17:20:50 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-06-16 17:20:50 +0000 |
commit | 026c09b6ce8e2f1e25e91d5a432a968e321d080e (patch) | |
tree | a13a81052f9fe40a1308d423f60aaa4a4c547c95 | |
parent | c409368062f569c5ef40f6f3094a98928d15f237 (diff) | |
download | brdo-026c09b6ce8e2f1e25e91d5a432a968e321d080e.tar.gz brdo-026c09b6ce8e2f1e25e91d5a432a968e321d080e.tar.bz2 |
- Bugfix: fixed searches to do boolean AND rather than OR. This isn't the best way to do things, but seems to be pretty much the only way to get things to be properly
ANSI-compliant. Patch by #17 by Al. (Note: I haven't really tested this fix but this should fix bug #1857.)
-rw-r--r-- | modules/search.module | 20 | ||||
-rw-r--r-- | modules/search/search.module | 20 |
2 files changed, 40 insertions, 0 deletions
diff --git a/modules/search.module b/modules/search.module index 31595ec5b..a34754134 100644 --- a/modules/search.module +++ b/modules/search.module @@ -129,6 +129,9 @@ function do_search($search_array) { $name = $row["name"]; $count = $row["count"]; + // Build reduction variable + $reduction[$lno][$word] = true; + // If the just fetched row is not already in the table if ($results[$lno]["lno"] != $lno) { $results[$lno]["count"] = $count; @@ -153,6 +156,23 @@ function do_search($search_array) { } if ($found) { + foreach ($results as $lno => $values) { + $pass = true; + foreach ($words as $word) { + if (!$reduction[$lno][$word]) { + $pass = false; + } + } + if ($pass) { + $fullresults[$lno] = $values; + } + } + $results = $fullresults; + if (!is_array($results)) { + $found = 0; + } + } + if ($found) { // Black magic here to sort the results array_multisort($results, SORT_DESC); diff --git a/modules/search/search.module b/modules/search/search.module index 31595ec5b..a34754134 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -129,6 +129,9 @@ function do_search($search_array) { $name = $row["name"]; $count = $row["count"]; + // Build reduction variable + $reduction[$lno][$word] = true; + // If the just fetched row is not already in the table if ($results[$lno]["lno"] != $lno) { $results[$lno]["count"] = $count; @@ -153,6 +156,23 @@ function do_search($search_array) { } if ($found) { + foreach ($results as $lno => $values) { + $pass = true; + foreach ($words as $word) { + if (!$reduction[$lno][$word]) { + $pass = false; + } + } + if ($pass) { + $fullresults[$lno] = $values; + } + } + $results = $fullresults; + if (!is_array($results)) { + $found = 0; + } + } + if ($found) { // Black magic here to sort the results array_multisort($results, SORT_DESC); |