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));
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

grndlvl’s picture

Status: Active » Needs review
FileSize
850 bytes
AlexisWilke’s picture

Status: Needs review » Fixed

Definitively wrong, indeed. Thank you for the patch. It's in the dev version.

aaron’s picture

Status: Fixed » Needs review
FileSize
2.74 KB

don't forget to update the comment counts for nodes prior to this patch. Patch attached.

AlexisWilke’s picture

Good 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

AlexisWilke’s picture

Issue summary: View changes

Adjusting for clarity.