I'm not sure if this is a bug with the comment module, but it looks like it might be.

In the Drupal tracker view, the Last Post column is wrong if you change the authoring date information in the node.

I think this is because the comment last updated information may be taken from the true node creation date and not from the authoring information authored on date.

Reproducing the bug
For example, create an unpublished node. Wait a day (or week or month). Then publish the node, but delete the contents of the authored on field so that the time of publishing becomes the authored on date.

Then go to /tracker and the Last Post colum will be incorrect. That column comes from "Comment: Last Comment Time" which seems to be taken from actual node creation time and not from authoring information time (i.e., user-set publication date).

The attached screenshot shows some posts that were published today (today's authored on date) that are showing in the tracker as being weeks old because the comment last updated field is not correct.

Expectation
I expect that the 'comment last updated field for a post with no comments would be the "authored on" date, not the actual date of node creation.

What happens
Posts with authoring date of today show as being weeks old in views if sorted by comment last updated field.

CommentFileSizeAuthor
#1 comment_bug.png12.83 KBZ2222

Comments

Z2222’s picture

StatusFileSize
new12.83 KB

My file didn't get attached to the post above so I'm attaching it here. The screenshot shows posts with the "authored on" date of today showing up in /tracker as being much older. The dates shown are the dates the first unpublished drafts of the nodes were created.

Anonymous’s picture

Status: Active » Postponed (maintainer needs more info)

We'll need to verify that the issue still exists with 6.2 but my guess is yes.

mouthings’s picture

Version: 5.7 » 6.12

This problem is still present in 6.12 as far as I can tell. If you edit the authored on date of a node with no comments, the last comment timestamp is not updated to match, so, for example topic list order in the forum module ends up being incorrect.

damien tournoud’s picture

Version: 6.12 » 7.x-dev
Status: Postponed (maintainer needs more info) » Active
Issue tags: +Novice

Bumping to D7 so that we fix that there first.

ergonlogic’s picture

Component: comment.module » tracker.module

I've been trying to replicate this bug in D7, but have been unable to do so. It appears to have been fixed by a prior refactoring. Also, unless I'm mistaken, the relevant code is in the tracker module (tracker.pages.inc, lines 43-46):

    $result = db_query('SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid WHERE n.nid IN (:nids)', array(':nids' => array_keys($nodes)), array('target' => 'slave'));
    foreach ($result as $node) {
      $node->last_activity = $nodes[$node->nid]->changed;
      $nodes[$node->nid] = $node;

Assuming I'm not missing something, ought this issue be marked fixed/closed, or the version switched back to 6.x-dev?

ergonlogic’s picture

Status: Active » Needs review
markabur’s picture

Component: tracker.module » comment.module
Status: Needs review » Needs work

I tried to reproduce the problem using Tracker module in D6 and D7. I enabled Tracker and Comment, created a couple of nodes, waited a minute and then updated the Authored On date for one of the nodes by blanking-out the field. In both D6 and D7 /tracker shows the new time just fine.

However if I enable Views and use its version of tracker, I see the issue as originally described. This is because the view is displaying the last comment date whereas Tracker is showing the node's last edit date. So, the last_comment_timestamp is out of sync with the node's authored-on date.

I think the crux of the problem is here, in line 2335 of comment.module:

  else {
    // Comments do not exist.
    $node = db_query('SELECT uid, created FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject();
    db_update('node_comment_statistics')
      ->fields(array(
        'cid' => 0,
        'comment_count' => 0,
        'last_comment_timestamp' => $node->created,
        'last_comment_name' => '',
        'last_comment_uid' => $node->uid,
      ))
      ->condition('nid', $nid)
      ->execute();
  }

...which supplies the node's creation date rather than its authored date if there are no comments.

markabur’s picture

Is it right that in addition to patching comment.module, we'd need to separately update node_comment_statistics for any existing comments to reflect this change?

markabur’s picture

Issue tags: -Novice

Dug into this a little more, and the actual problem is that the comment_statistics are not updated when the node's creation date is changed. comment_statistics is filled in with the node creation date when the node is first created, but isn't updated again until a comment is added. So, if a post is created, then back-dated (or as in the OP, forward-dated), the last_comment_timestamp will be wrong until a comment is added. Seems like the only way to fix this would be to update comment_statistics on every node update, in case the date changed.

jonathan webb’s picture

Status: Needs work » Closed (duplicate)

This issue is a duplicate of #55246: Node updates are not reflected in node_comment_statistics correctly which regards a similar issue which occurs when changing the node author.