Skip to content

Keep spam and trash comments out of the moderation queue - #28

Merged
GaryJones merged 1 commit into
developfrom
GaryJones/fix-issue-16
Aug 19, 2026
Merged

GaryJones merged 1 commit into
developfrom
GaryJones/fix-issue-16

Conversation

@GaryJones

Copy link
Copy Markdown
Contributor

Summary

Once a comment reached the report threshold, mark_flagged() set its status to hold unconditionally. 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_flagged action now fires only when a comment is genuinely flagged, which is the more accurate signal for anything hooking into it.

Fixes #16

Test plan

  • Enable flagging with a threshold (e.g. 4)
  • Mark a comment as spam or move it to trash
  • Report that comment enough times to cross the threshold
  • Confirm it stays in spam/trash rather than returning to the moderation queue
  • Report an approved comment past the threshold and confirm it is still moved to hold

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
@GaryJones GaryJones added the bug label Aug 19, 2026
@GaryJones GaryJones added this to the Next milestone Aug 19, 2026
@GaryJones
GaryJones merged commit 201a606 into develop Aug 19, 2026
6 checks passed
@GaryJones
GaryJones deleted the GaryJones/fix-issue-16 branch August 19, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mark_flagged() pushes trashed/spam comments to moderation queue without checking current status

1 participant