When a comment is published or unpublished the node_comment_statistics table must be updated by the caller. There's a helper function in the comments module that can do it: _comment_update_node_comment_statistics($nid). This function is not called automatically by the comments module.

Comments

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new1.07 KB

It's not so good that this module doesn't use comment_save,
because it does all the logic for us.

To be fair neither comment_publish_action nor comment_unpublish_action recalculate the statistics, too

stefan freudenberg’s picture

Thanks for the patch. Overall the comment module is a bit murky when it comes to publishing/unpublishing. If you change the status to published comment_save_comment() will invoke hook_comment() twice providing update and publish as operation parameter. But if you unpublish a comment that way only the update operation will be invoked.

At first sight it's pretty stunning that the comment actions don't do the job. The idea behind not updating node_comment_statistics in the publish/unpublish operation is that you might publish or unpublish more than one comment of the same node in a mass action and it would be much more efficient to update the node_comment_statistics table only once for each relevant node.

sanduhrs’s picture

Status: Needs review » Reviewed & tested by the community

Commited.
Thanks for the patch.

sanduhrs’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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