http://api.drupal.org/api/function/comment_enable/7 adds entries into {node_comment_statistics} for nodes that have no entry. The timestamp of the last comment is set to be n.changed, where it should be n.created.

The n.changed was probably copied over from http://api.drupal.org/api/function/comment_nodeapi/6 (see case when $op is 'insert'), though of course on node creation n.changed is just the creation date/time.

Also note the following comment in http://api.drupal.org/api/function/_comment_update_node_statistics/7:

last_comment_timestamp: the timestamp of the last comment for this node or the node create stamp if no comments exist for the node

I hit this in 5.22 but the problem is clearly still there in 6.x and 7.x.

Related:
#580638: {node_comment_statistics} not updated with altered author
#102766: Tracker displays "0" and incorrect last update for nodes if comments are made but comment module is disabled
#87590: Tracker is not comment.module-proof
and see also page "How to rebuild node_comment_statistics" http://drupal.org/node/137458

CommentFileSizeAuthor
#3 last_comment_timestamp.patch625 bytesgpk
#1 last_comment_timestamp.patch593 bytesgpk
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gpk’s picture

Status: Active » Needs review
FileSize
593 bytes

Completely untested patch.

Might also want an update routine to correct existing timestamps (because for example if comment.module is first enabled part-way through the life of a site when there is existing content then those existing nodes will have the last_comment_timestamp set to their changed timestamp but new nodes will have it set to their created timestamp. This can make the tracker listing appear pretty random, especially any of the original nodes that still have no comments are updated - their last_comment_timestamp will then be the timestamp of the latest revision before comment.module was enabled).

Status: Needs review » Needs work

The last submitted patch, last_comment_timestamp.patch, failed testing.

gpk’s picture

Status: Needs work » Needs review
FileSize
625 bytes

Try again with right patch format this time hopefully.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community
Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

gpk’s picture

Version: 7.x-dev » 6.x-dev
Status: Closed (fixed) » Patch (to be ported)

Could do with backport to 6.x and 5.x.

And probably also an update routine to ensure consistency of last_comment_timestamp (which could currently be a mixture of n.created and c.changed) for nodes with 0 comments. However my SQL is not good enough to make a core-worthy patch for that..!

Status: Patch (to be ported) » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.