Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.617.2.2 diff -u -F^f -r1.617.2.2 comment.module --- modules/comment/comment.module 25 Apr 2008 20:58:46 -0000 1.617.2.2 +++ modules/comment/comment.module 8 Jul 2008 15:16:01 -0000 @@ -594,8 +594,10 @@ function comment_form_alter(&$form, $for function comment_nodeapi(&$node, $op, $arg = 0) { switch ($op) { case 'load': - return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid)); - break; + if ($node->comment != COMMENT_NODE_DISABLED) { + return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid)); + } + return array('last_comment_timestamp' => $node->created, 'last_comment_name' => '', 'comment_count' => 0); case 'prepare': if (!isset($node->comment)) { @@ -614,23 +616,26 @@ function comment_nodeapi(&$node, $op, $a case 'update index': $text = ''; - $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = %d', $node->nid, COMMENT_PUBLISHED); - while ($comment = db_fetch_object($comments)) { - $text .= '

'. check_plain($comment->subject) .'

'. check_markup($comment->comment, $comment->format, FALSE); + if ($node->comment != COMMENT_NODE_DISABLED) { + $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = %d', $node->nid, COMMENT_PUBLISHED); + while ($comment = db_fetch_object($comments)) { + $text .= '

'. check_plain($comment->subject) .'

'. check_markup($comment->comment, $comment->format, FALSE); + } } return $text; case 'search result': - $comments = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $node->nid)); - return format_plural($comments, '1 comment', '@count comments'); + if ($node->comment != COMMENT_NODE_DISABLED) { + $comments = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $node->nid)); + return format_plural($comments, '1 comment', '@count comments'); + } + return ''; case 'rss item': if ($node->comment != COMMENT_NODE_DISABLED) { return array(array('key' => 'comments', 'value' => url('node/'. $node->nid, array('fragment' => 'comments', 'absolute' => TRUE)))); } - else { - return array(); - } + return array(); } }