Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The comment count is not being updated when marking content as not spam.
Turns out this is because the wrong the wrong $nid is being returned for the call to _comment_update_node_statistics() during the publish op in comment_spamapi.
@ Line #212.
$nid = db_result(db_query('SELECT nid FROM {comments} WHERE cid = %d AND status = %d OR status = %d', $arg1, COMMENT_NOT_PUBLISHED, SPAM_COMMENT));
Should be changed to:
$nid = db_result(db_query('SELECT nid FROM {comments} WHERE cid = %d AND (status = %d OR status = %d)', $arg1, COMMENT_NOT_PUBLISHED, SPAM_COMMENT));
Comment | File | Size | Author |
---|---|---|---|
#3 | update-comment-count-1861376-3.patch | 2.74 KB | aaron |
#1 | spam-spam_content_comment-publish_right_nid.1861376.1.patch | 850 bytes | grndlvl |
Comments
Comment #1
grndlvl CreditAttribution: grndlvl commentedComment #2
AlexisWilke CreditAttribution: AlexisWilke commentedDefinitively wrong, indeed. Thank you for the patch. It's in the dev version.
Comment #3
aaron CreditAttribution: aaron commenteddon't forget to update the comment counts for nodes prior to this patch. Patch attached.
Comment #4
AlexisWilke CreditAttribution: AlexisWilke commentedGood point. Now that's a bigger patch so I cannot just put it in. I reviewed it and it looks good to me, although I don't know everything about batches, especially while working in an update environment.
We'll see if one of the other maintainers can do the update.
Just in case, this is used to fix all the comment counters because they were wrong before having the previous patch installed. So users with versions that were affected by the previous bug (the OR without parenthesis) would have wrong counts for all their comments.
Thank you.
Alexis Wilke
Comment #4.0
AlexisWilke CreditAttribution: AlexisWilke commentedAdjusting for clarity.