Skip to content

Fix comment moderation sorting with missing meta#538

Merged
dkotter merged 1 commit into
WordPress:developfrom
ekamran:shifteq/fix-comment-moderation-sort-missing-meta
May 13, 2026
Merged

Fix comment moderation sorting with missing meta#538
dkotter merged 1 commit into
WordPress:developfrom
ekamran:shifteq/fix-comment-moderation-sort-missing-meta

Conversation

@ekamran
Copy link
Copy Markdown
Contributor

@ekamran ekamran commented May 12, 2026

What?

Follow up to #518.

Fixes Comment Moderation sorting so comments without AI moderation metadata stay visible when sorting by Sentiment or Toxicity.

Why?

The comments list can include both analyzed and unanalyzed comments. Before this change, sorting by Sentiment or Toxicity used meta_key sorting, which only returns comments that have that meta key. As a result, unanalyzed comments disappeared from the list even though the total item count still included them.

How?

  • Updates the Comment Moderation sort query to use named meta_query clauses for comments with and without moderation metadata.
  • Keeps existing Sentiment and Toxicity filtering behavior unchanged.
  • Adds integration test coverage for Sentiment and Toxicity sorting in both ascending and descending order.
  • Confirms comments without moderation metadata remain included in sorted results.

Use of AI Tools

AI assistance: Yes
Tool(s): ChatGPT / Codex
Used for: Helping inspect the repository, draft and iterate on the patch, run local verification commands, and review the PR description. I manually reviewed the implementation, validated the behavior locally, and verified the final test results before submitting.

Testing Instructions

  1. Enable the Comment Moderation experiment.
  2. Create or use comments where some have AI moderation metadata and some do not.
  3. Go to wp-admin/edit-comments.php.
  4. Sort by the Sentiment column.
  5. Confirm comments without Sentiment metadata remain visible.
  6. Sort by the Toxicity column.
  7. Confirm comments without Toxicity metadata remain visible.
  8. Run:
composer run-script test
composer run-script lint
composer run-script phpstan

Screenshots or screencast

Not applicable. This fixes list table sorting behavior and is covered by integration tests.

Changelog Entry

Fixed - Keep comments without AI moderation metadata visible when sorting Comment Moderation columns.

Open WordPress Playground Preview

@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ekamran <ekamran@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.88%. Comparing base (27ac41f) to head (34efc7a).

Files with missing lines Patch % Lines
...eriments/Comment_Moderation/Comment_Moderation.php 96.15% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #538      +/-   ##
=============================================
+ Coverage      70.72%   70.88%   +0.16%     
  Complexity      1144     1144              
=============================================
  Files             67       67              
  Lines           5510     5530      +20     
=============================================
+ Hits            3897     3920      +23     
+ Misses          1613     1610       -3     
Flag Coverage Δ
unit 70.88% <96.15%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkotter dkotter added this to the 1.0.0 milestone May 13, 2026
@dkotter dkotter merged commit 432e1c6 into WordPress:develop May 13, 2026
18 checks passed
@ekamran ekamran deleted the shifteq/fix-comment-moderation-sort-missing-meta branch May 17, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants