Closed (outdated)
Project:
Drupal core
Version:
7.x-dev
Component:
comment.module
Priority:
Minor
Category:
Bug report
Assigned:
Reporter:
Created:
25 Jul 2014 at 20:33 UTC
Updated:
14 Sep 2017 at 22:12 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dcam commentedThank you for your report! I think that I understand what you say is happening, but I would really appreciate it if you could provide us with steps to reproduce this issue. That way there's no confusion.
Comment #2
coolestdude1 commenteddcam, sure thing.
1. Create content type with comments enabled
2. Create a node
3. Create a comment on that node
4. Check the node statistics table, the comment count for the node created earlier should now be 1
5. Use the comment module api to unpublish the comment created earlier
6. Check the node statistics table again and the comment count will remain at 1
7. Run _comment_update_node_statistics() on the node created
8. Check the node statistics table again and the comment count will now be 0
Issue arises from updating comment table directly with an SQL call rather than using comments internal functions for unpublishing a node. Affects contrib/custom modules trying to call the comment api as intended.
Comment #3
coolestdude1 commentedPushing back after proper steps to reproduce given, issue is still a problem at 7.41
Comment #4
markot91 commentedComment #5
tinko commentedHello,
The field comment_count in table node_comment_statistics is for the count of published comments on the node.
If you unpublish a comment programmatically the function _comment_update_node_statistics() is never called to update statistics and that is why you still get the comment_count: 1, but when the function is called she updates the comment_count.
You have to do the actions on comments and the statistics update together (if you are doing it programmatically)
Greetings
Comment #6
tinko commentedHello,
Here is the patch for updating statistic when publish/unpublish comment with the api functions comment_publish_action() and comment_unpublish_action().
Greetings