Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.636 diff -u -p -r1.636 comment.module --- modules/comment/comment.module 14 Jun 2008 16:02:49 -0000 1.636 +++ modules/comment/comment.module 16 Jun 2008 06:57:43 -0000 @@ -418,10 +418,9 @@ function comment_link($type, $node = NUL if ($teaser) { // Main page: display the number of comments that have been posted. if (user_access('access comments')) { - $all = comment_num_all($node->nid); - if ($all) { + if ($node->comment_count) { $links['comment_comments'] = array( - 'title' => format_plural($all, '1 comment', '@count comments'), + 'title' => format_plural($node->comment_count, '1 comment', '@count comments'), 'href' => "node/$node->nid", 'attributes' => array('title' => t('Jump to the first comment of this posting.')), 'fragment' => 'comments' @@ -432,7 +431,7 @@ function comment_link($type, $node = NUL $links['comment_new_comments'] = array( 'title' => format_plural($new, '1 new comment', '@count new comments'), 'href' => "node/$node->nid", - 'query' => comment_new_page_count($all, $new, $node), + 'query' => comment_new_page_count($node->comment_count, $new, $node), 'attributes' => array('title' => t('Jump to the first new comment of this posting.')), 'fragment' => 'new' ); @@ -1086,24 +1085,6 @@ function comment_load($cid) { } /** - * Get comment count for a node. - * - * @param $nid - * The node id. - * @return - * The comment count. - */ -function comment_num_all($nid) { - static $cache; - - if (!isset($cache[$nid])) { - $cache[$nid] = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $nid)); - } - - return $cache[$nid]; -} - -/** * Get replies count for a comment. * * @param $pid Index: modules/comment/comment.test =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.test,v retrieving revision 1.7 diff -u -p -r1.7 comment.test --- modules/comment/comment.test 14 Jun 2008 16:02:50 -0000 1.7 +++ modules/comment/comment.test 16 Jun 2008 06:57:43 -0000 @@ -27,7 +27,7 @@ class CommentTestCase extends DrupalWebT $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create article content')); $this->drupalLogin($this->web_user); - $this->node = $this->drupalCreateNode(array('type' => 'article')); + $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); $this->assertTrue($this->node, t('Article node created.')); $this->drupalLogout(); } @@ -68,6 +68,10 @@ class CommentTestCase extends DrupalWebT $this->drupalGet('comment/edit/' . $reply->id); $reply = $this->postComment(NULL, $this->randomName(), $this->randomName()); $this->assertTrue($this->commentExists($reply, TRUE), t('Modified reply found.')); + + // Correct link count + $this->drupalGet('node'); + $this->assertRaw('2 comments', t('Link to the 2 comments exist. %s')); // Pager $this->setCommentsPerPage(2);