close
Skip to content

Fix automatic comment moderation without provider#554

Merged
dkotter merged 1 commit into
WordPress:developfrom
ekamran:shifteq/fix-comment-moderation-auto-no-provider
May 14, 2026
Merged

Fix automatic comment moderation without provider#554
dkotter merged 1 commit into
WordPress:developfrom
ekamran:shifteq/fix-comment-moderation-auto-no-provider

Conversation

@ekamran
Copy link
Copy Markdown
Contributor

@ekamran ekamran commented May 14, 2026

What?

Prevents automatic Comment Moderation from attempting to analyze newly inserted comments when no AI provider credentials are configured.

Why?

Manual Comment Moderation actions already avoid running analysis without provider credentials. The automatic wp_insert_comment path did not, which could silently mark new comments with _wpai_analysis_status=failed even though no provider was configured.

How?

  • Added an early credentials check before automatic comment analysis runs.
  • Added a regression test to confirm no moderation meta is written when credentials are missing.

Testing Instructions

  1. Enable the AI plugin and Comment Moderation experiment.
  2. Ensure no AI provider credentials are configured.
  3. Add a new comment.
  4. Confirm the comment is not marked with _wpai_analysis_status=failed.

Tested locally with:

vendor/bin/phpunit -c phpunit.xml.dist tests/Integration/Includes/Experiments/Comment_Moderation/Comment_ModerationTest.php
composer run-script lint

<!-- wp-playground-preview:start -->
<a href="https://playground.wordpress.net?blueprint-url=data:application/json,%7B%22preferredVersions%22%3A%7B%22wp%22%3A%22beta%22%7D%2C%22steps%22%3A%5B%7B%22step%22%3A%22installPlugin%22%2C%22pluginData%22%3A%7B%22resource%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2FWordPress%2Fai%2Freleases%2Fdownload%2Fci-artifacts%2Fpr-554-00550cbd0065897bd318ea59eb6f7db5e5178058.zip%22%7D%7D%5D%7D" target="_blank" rel="noopener noreferrer">
  <img src="https://raw.githubusercontent.com/adamziel/playground-preview/refs/heads/trunk/assets/playground-preview-button.svg" alt="Open WordPress Playground Preview" width="220" height="57" />
</a>
<!-- wp-playground-preview:end -->

@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 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.21%. Comparing base (de6371e) to head (00550cb).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #554      +/-   ##
=============================================
+ Coverage      71.20%   71.21%   +0.01%     
- Complexity      1150     1151       +1     
=============================================
  Files             67       67              
  Lines           5563     5565       +2     
=============================================
+ Hits            3961     3963       +2     
  Misses          1602     1602              
Flag Coverage Δ
unit 71.21% <100.00%> (+0.01%) ⬆️

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 14, 2026
@dkotter dkotter merged commit 7888332 into WordPress:develop May 14, 2026
18 checks passed
@ekamran ekamran deleted the shifteq/fix-comment-moderation-auto-no-provider branch May 17, 2026 16:21
simison pushed a commit to simison/ai that referenced this pull request May 25, 2026
Fixed - Prevent analyzing newly inserted comments when no provider is configured.

Co-authored-by: ekamran <ekamran@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
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