Index: modules/comment/views_handler_field_node_new_comments.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/comment/views_handler_field_node_new_comments.inc,v retrieving revision 1.7.4.1 diff -u -p -r1.7.4.1 views_handler_field_node_new_comments.inc --- modules/comment/views_handler_field_node_new_comments.inc 2 Nov 2009 22:01:26 -0000 1.7.4.1 +++ modules/comment/views_handler_field_node_new_comments.inc 3 Nov 2009 22:10:00 -0000 @@ -63,9 +63,16 @@ class views_handler_field_node_new_comme } if ($nids) { - $result = db_query("SELECT n.nid, COUNT(c.cid) as num_comments FROM {node} n INNER JOIN {comments} c ON n.nid = c.nid LEFT JOIN {history} h ON h.nid = n.nid AND h.uid = %d WHERE n.nid IN (" . implode(', ', $nids) . ") AND c.timestamp > GREATEST(COALESCE(h.timestamp, %d), %d) AND c.status = %d GROUP BY n.nid ", $user->uid, NODE_NEW_LIMIT, NODE_NEW_LIMIT, COMMENT_PUBLISHED); + $result = db_query("SELECT n.nid, COUNT(c.cid) as num_comments FROM {node} n INNER JOIN {comment} c ON n.nid = c.nid + LEFT JOIN {history} h ON h.nid = n.nid AND h.uid = :h_uid WHERE n.nid IN (:nids) + AND c.changed > GREATEST(COALESCE(h.timestamp, :timestamp), :timestamp) AND c.status = :status GROUP BY n.nid ", array( + ':status' => COMMENT_PUBLISHED, + ':h_uid' => $user->uid, + ':nids' => $nids, + ':timestamp' => NODE_NEW_LIMIT, + )); - while ($node = db_fetch_object($result)) { + foreach ($result as $node) { foreach ($ids[$node->nid] as $id) { $values[$id]->{$this->field_alias} = $node->num_comments; }