From 90e67a3acb226d7d0f45ecd117c1fcfcbe4f0b24 Mon Sep 17 00:00:00 2001 From: Steven Wittens <steven@10.no-reply.drupal.org> Date: Thu, 18 Nov 2004 21:16:30 +0000 Subject: [PATCH] Search indexing bug: last updated timestamp needs to take last comment timestamp into account. --- modules/node.module | 5 +++-- modules/node/node.module | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/node.module b/modules/node.module index 30fc7c4ab049..672b3bdb1f0b 100644 --- a/modules/node.module +++ b/modules/node.module @@ -1546,16 +1546,17 @@ function node_update_index() { $last = variable_get('node_cron_last', 0); $limit = (int)variable_get('search_cron_limit', 100); - $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); + $result = db_query_range('SELECT n.nid, c.last_comment_timestamp 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)) { + $last_comment = $node->last_comment_timestamp; $node = node_load(array('nid' => $node->nid)); // We update this variable per node in case cron times out, or if the node // cannot be indexed (PHP nodes which call drupal_goto, for example). // In rare cases this can mean a node is only partially indexed, but the // chances of this happening are very small. - variable_set('node_cron_last', max($node->changed, $node->created)); + variable_set('node_cron_last', max($last_comment, max($node->changed, $node->created))); if (node_hook($node, 'view')) { node_invoke($node, 'view', false, false); diff --git a/modules/node/node.module b/modules/node/node.module index 30fc7c4ab049..672b3bdb1f0b 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1546,16 +1546,17 @@ function node_update_index() { $last = variable_get('node_cron_last', 0); $limit = (int)variable_get('search_cron_limit', 100); - $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); + $result = db_query_range('SELECT n.nid, c.last_comment_timestamp 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)) { + $last_comment = $node->last_comment_timestamp; $node = node_load(array('nid' => $node->nid)); // We update this variable per node in case cron times out, or if the node // cannot be indexed (PHP nodes which call drupal_goto, for example). // In rare cases this can mean a node is only partially indexed, but the // chances of this happening are very small. - variable_set('node_cron_last', max($node->changed, $node->created)); + variable_set('node_cron_last', max($last_comment, max($node->changed, $node->created))); if (node_hook($node, 'view')) { node_invoke($node, 'view', false, false); -- GitLab