Repository navigation
Keep spam and trash comments out of the moderation queue - #28
Merged
Merged
Conversation
Reporting a comment that had already been marked as spam by Akismet or trashed by a moderator would push it straight back into the moderation queue once the report threshold was reached, because mark_flagged() set the status to hold without checking the comment's current state. The existing moderated guard only covered comments that had been approved, so anything sent directly to spam or trash was left unprotected. Restrict the status change to comments that are currently approved, so already-actioned comments are left where the moderator put them. Fixes #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Once a comment reached the report threshold,
mark_flagged()set its status toholdunconditionally. This meant a comment that Akismet had already caught as spam, or that a moderator had already trashed, would be dragged back into the moderation queue the moment enough visitors reported it. From the moderator's point of view, comments they had already dealt with kept reappearing.The plugin does have a guard against re-flagging, but it only protects comments that reached the approved state via
comment_unapproved_to_approved. Anything sent straight to spam or trash never sets that flag, so it was left unprotected.This change restricts the status change to comments that are currently approved. Approved comments are still pulled into moderation as before, while spam and trashed comments are left exactly where the moderator (or Akismet) put them. The
safe_report_comments_mark_flaggedaction now fires only when a comment is genuinely flagged, which is the more accurate signal for anything hooking into it.Fixes #16
Test plan