From 026c09b6ce8e2f1e25e91d5a432a968e321d080e Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 16 Jun 2003 17:20:50 +0000 Subject: - 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.) --- modules/search.module | 20 ++++++++++++++++++++ modules/search/search.module | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'modules') 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; @@ -152,6 +155,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; @@ -152,6 +155,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); -- cgit v1.2.3