On views module we have created a list of teasers which was supposed to list the latest nodes in order of the latest posted comment.
So we went down to Sort Criteria section of views and selected :
Field: Comment: Last Comment Date
Option: Normal
Order: Descending
It did not work how it supposed to be after a few trials.
When I checked it further any new comment was not updating the timestamp on node_comment_statistics table with the latest comment's timestamp at it supposed to be.
So I went to comment.module and checked the code below:
// comments exist
if ($count > 0) {
$last_reply = db_fetch_object(db_query_range('SELECT cid, name, timestamp, uid FROM {comments} WHERE nid = %d AND status = %d ORDER BY cid DESC', $nid, COMMENT_PUBLISHED, 0, 1));
db_query("UPDATE {node_comment_statistics} SET comment_count = %d, last_comment_timestamp = %d, last_comment_name = '%s', last_comment_uid = %d WHERE nid = %d", $count, $last_reply->timestamp, $last_reply->uid ? '' : $last_reply->name, $last_reply->uid, $nid);
}
It is just looking fine but was not working and sorting as it supposed to be.
So I went and changed:
cid to timestamp
as below:
// comments exist
if ($count > 0) {
$last_reply = db_fetch_object(db_query_range('SELECT cid, name, timestamp, uid FROM {comments} WHERE nid = %d AND status = %d ORDER BY timestamp DESC', $nid, COMMENT_PUBLISHED, 0, 1));
db_query("UPDATE {node_comment_statistics} SET comment_count = %d, last_comment_timestamp = %d, last_comment_name = '%s', last_comment_uid = %d WHERE nid = %d", $count, $last_reply->timestamp, $last_reply->uid ? '' : $last_reply->name, $last_reply->uid, $nid);
}
and it worked as it supposed to be.
The comment module is // $Id: comment.module,v 1.520.2.2 2007/01/29 21:51:53 drumm Exp $
I know it is strange, and I dont supposed to touch a core module, and "cid DESC" should also work. I just would like to know if this is a bug related to another issue or should be resolved as is or can be patched using this way and applied to the latest releases.
Thanks,
Mark Ercil
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.