********Index: node.module =================================================================== RCS file: /usr/local/cvs/requiem/modules/node.module,v retrieving revision 1.3 retrieving revision 1.5 diff -u -r1.3 -r1.5 --- node.module 12 Jan 2006 00:40:42 -0000 1.3 +++ node.module 12 Jan 2006 19:53:10 -0000 1.5 @@ -1,5 +1,5 @@ %d OR n.changed > %d OR c.last_comment_timestamp > %d)', $last, $last, $last)); + // Remaing SQL uses GREATEST in the where clause instead of ORs on purpose to maintain integretiy of indexing multiple nodes with the same greatest change timestamp + $remaining = db_result(db_query('SELECT COUNT(*) FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.status = 1 AND n.moderate = 0 AND ((GREATEST(n.created, n.changed, c.last_comment_timestamp) = %d AND n.nid > %d ) OR (n.created > %d OR n.changed > %d OR c.last_comment_timestamp > %d))', $last, $last_nid, $last, $last, $last)); return array('remaining' => $remaining, 'total' => $total); case 'admin': @@ -2074,23 +2077,27 @@ */ function node_update_index() { $last = variable_get('node_cron_last', 0); + $last_nid = variable_get('node_cron_last_nid', 0); $limit = (int)variable_get('search_cron_limit', 100); // Store the maximum possible comments per thread (used for ranking by reply count) variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')))); variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}')))); - $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); + // Result SQL uses GREATEST in the where clause instead of ORs on purpose to maintain integretiy of indexing multiple nodes with the same greatest change timestamp + $result = db_query_range('SELECT GREATEST(c.last_comment_timestamp, n.changed, n.created) as last_change, 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 ((GREATEST(n.created, n.changed, c.last_comment_timestamp) = %d AND n.nid > %d) OR (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, n.nid ASC', $last, $last_nid, $last, $last, $last, 0, $limit); while ($node = db_fetch_object($result)) { - $last_comment = $node->last_comment_timestamp; + $last_change = $node->last_change; + $last_node = $node->nid; $node = node_load($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($last_comment, $node->changed, $node->created)); + variable_set('node_cron_last', $last_change); + variable_set('node_cron_last_nid', $last_node); // Get node output (filtered and with module-specific fields). if (node_hook($node, 'view')) {