Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.909
diff -u -p -r1.909 comment.module
--- modules/comment/comment.module	28 Oct 2010 17:40:30 -0000	1.909
+++ modules/comment/comment.module	28 Oct 2010 22:19:21 -0000
@@ -595,15 +595,13 @@ function theme_comment_block() {
 function comment_node_view($node, $view_mode) {
   $links = array();
 
-  if ($node->comment) {
+  if ($node->comment != COMMENT_NODE_HIDDEN) {
     if ($view_mode == 'rss') {
-      if ($node->comment != COMMENT_NODE_HIDDEN) {
-        // Add a comments RSS element which is a URL to the comments of this node.
-        $node->rss_elements[] = array(
-          'key' => 'comments',
-          'value' => url('node/' . $node->nid, array('fragment' => 'comments', 'absolute' => TRUE))
-        );
-      }
+      // Add a comments RSS element which is a URL to the comments of this node.
+      $node->rss_elements[] = array(
+        'key' => 'comments',
+        'value' => url('node/' . $node->nid, array('fragment' => 'comments', 'absolute' => TRUE))
+      );
     }
     elseif ($view_mode == 'teaser') {
       // Teaser view: display the number of comments that have been posted,
@@ -685,7 +683,7 @@ function comment_node_view($node, $view_
     // page. We compare $node and $page_node to ensure that comments are not
     // appended to other nodes shown on the page, for example a node_reference
     // displayed in 'full' view mode within another node.
-    if ($node->comment && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview) && user_access('access comments')) {
+    if ($view_mode == 'full' && node_is_page($node) && empty($node->in_preview) && user_access('access comments')) {
       $node->content['comments'] = comment_node_page_additions($node);
     }
   }
Index: modules/comment/comment.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.test,v
retrieving revision 1.90
diff -u -p -r1.90 comment.test
--- modules/comment/comment.test	5 Oct 2010 06:17:28 -0000	1.90
+++ modules/comment/comment.test	28 Oct 2010 22:19:22 -0000
@@ -390,6 +390,35 @@ class CommentInterfaceTest extends Comme
     $this->drupalLogin($this->admin_user);
     $this->setCommentForm(FALSE);
   }
+
+  /**
+   * Tests whether "@count new comments" indicators show and link correctly.
+   */
+  public function testCommentNewCommentsIndicator() {
+    $this->drupalLogin($this->admin_user);
+    // Test if the right links are displayed when no comment is present for the node.
+    $this->drupalGet('node');
+    $this->assertLink(t('Add new comment'));
+    $this->assertNoLink(t('@count comments', array('@count' => 0)));
+    $this->assertNoLink(t('@count new comments', array('@count' => 0)));
+    // Post comment with admin user, check links for web user.
+    $this->postComment($this->node, $this->randomString(), $this->randomString());
+    $this->drupalGet('node');
+    $this->drupalLogout();
+    // Login whith web user and check links.
+    $this->drupalLogin($this->web_user);
+    $this->drupalGet('node');
+    $this->assertNoLink(t('Add new comment'));
+    $this->assertLink(t('1 new comment'));
+    $this->clickLink(t('1 new comment'));
+    $this->assertRaw('<span class="new">' . t('new') . '</span>', t('Found "new" marker.'));
+    $this->assertTrue($this->xpath('//a[@id=:new]/following-sibling::a[1][@id=:comment_id]', array(':new' => 'new', ':comment_id' => 'comment-1')), t('The "new" anchor is positioned at the right comment.'));
+    // Test if "new comment" link is correctly removed.
+    $this->drupalGet('node');
+    $this->assertLink(t('1 comment'));
+    $this->assertNoLink(t('1 new comment'));
+    $this->assertNoLink(t('@count new comments', array('@count' => 0)));
+  }
 }
 
 /**
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1314
diff -u -p -r1.1314 node.module
--- modules/node/node.module	27 Oct 2010 18:45:55 -0000	1.1314
+++ modules/node/node.module	28 Oct 2010 22:19:26 -0000
@@ -1362,11 +1362,14 @@ function node_show($node, $message = FAL
     drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))), PASS_THROUGH);
   }
 
+  // For markup consistency with other pages, use node_view_multiple() rather than node_view().
+  $output = node_view_multiple(array($node->nid => $node), 'full');
+
   // Update the history table, stating that this user viewed this node.
+  // We can't do this before calling node_view_multiple() since that would mess up comments' "new" status.
   node_tag_new($node);
 
-  // For markup consistency with other pages, use node_view_multiple() rather than node_view().
-  return node_view_multiple(array($node->nid => $node), 'full');
+  return $output;
 }
 
 /**
