From b6eee48c887e66b195a2b88fe905872af83bbade Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 4 Nov 2004 06:47:03 +0000 Subject: - Patch #12232 by Steven: more search improvements: + When a comment is posted, a node needs to be re-indexed. Luckily, we can use node_comment_statistics for this easily. + When a node is deleted, it should be deleted from the search index as well. + The search wipe didn't properly remove links to nodes from the index. + Section url was faulty in _help. + Minor code rearrangement. --- modules/node.module | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'modules/node.module') diff --git a/modules/node.module b/modules/node.module index 501272ae2..1f2b24f0d 100644 --- a/modules/node.module +++ b/modules/node.module @@ -1409,6 +1409,9 @@ function node_delete($edit) { // Clear the cache so an anonymous poster can see the node being deleted. cache_clear_all(); + // Remove this node from the search index + search_wipe($node->nid, 'node'); + watchdog('special', t('%type: deleted %title.', array('%type' => ''. t($node->type) .'', '%title' => "$node->title"))); $output = t('The node has been deleted.'); } @@ -1515,7 +1518,7 @@ function node_update_index() { $last = variable_get('node_cron_last', 0); $limit = (int)variable_get('search_cron_limit', 100); - $result = db_query_range('SELECT nid FROM {node} n WHERE n.status = 1 AND moderate = 0 AND (created > %d OR changed > %d) ORDER BY GREATEST(created, changed) ASC', $last, $last, 0, $limit); + $result = db_query_range('SELECT n.nid FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.status = 1 AND n.moderate = 0 AND (n.created > %d OR n.changed > %d OR c.last_comment_timestamp > %d) ORDER BY GREATEST(n.created, n.changed, c.last_comment_timestamp) ASC', $last, $last, $last, 0, $limit); while ($node = db_fetch_object($result)) { $node = node_load(array('nid' => $node->nid)); -- cgit v1.2.3