diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-05-10 07:52:52 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-05-10 07:52:52 +0000 |
commit | 2305812e8a5e0b4bdfafe0a8005056a441ddc2db (patch) | |
tree | 8f98718d9c952516a40be960afccf1205b28a83d /modules/node/node.module | |
parent | f50062676eabef53f84f426aaa110ee8a0815ee2 (diff) | |
download | brdo-2305812e8a5e0b4bdfafe0a8005056a441ddc2db.tar.gz brdo-2305812e8a5e0b4bdfafe0a8005056a441ddc2db.tar.bz2 |
- Patch #252580 by robert douglas and senpai: fixed a division by zero.
Diffstat (limited to 'modules/node/node.module')
-rw-r--r-- | modules/node/node.module | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/modules/node/node.module b/modules/node/node.module index ede648a26..18031a0b6 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1272,12 +1272,22 @@ function node_search($op = 'search', $keys = NULL) { $join2 .= ' LEFT JOIN {node_counter} nc ON nc.nid = i.sid'; $total += $weight; } - $select2 = (count($ranking) ? implode(' + ', $ranking) : 'i.relevance') . ' AS score'; - // Do search + // When all search factors are disabled (ie they have a weight of zero), + // the default score is based only on keyword relevance and there is no need to + // adjust the score of each item. + if ($total == 0) { + $select2 = 'i.relevance AS score'; + $total = 1; + } + else { + $select2 = implode(' + ', $ranking) . ' AS score'; + } + + // Do search. $find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid ' . $join1 . ' INNER JOIN {users} u ON n.uid = u.uid', $conditions1 . (empty($where1) ? '' : ' AND ' . $where1), $arguments1, $select2, $join2, $arguments2); - // Load results + // Load results. $results = array(); foreach ($find as $item) { // Build the node body. @@ -1286,9 +1296,9 @@ function node_search($op = 'search', $keys = NULL) { $node = node_build_content($node, FALSE, FALSE); $node->body = drupal_render($node->content); - // Fetch comments for snippet + // Fetch comments for snippet. $node->body .= module_invoke('comment', 'nodeapi', $node, 'update index'); - // Fetch terms for snippet + // Fetch terms for snippet. $node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index'); $extra = node_invoke_nodeapi($node, 'search result'); |