Skip to content

Fix global AI enabled option migration#586

Merged
dkotter merged 3 commits into
WordPress:developfrom
ekamran:shifteq/fix-global-toggle-upgrade-migration
May 19, 2026
Merged

Fix global AI enabled option migration#586
dkotter merged 3 commits into
WordPress:developfrom
ekamran:shifteq/fix-global-toggle-upgrade-migration

Conversation

@ekamran
Copy link
Copy Markdown
Contributor

@ekamran ekamran commented May 19, 2026

What?

Fixes migration of the global AI enabled setting from older AI Experiments installs.

Why?

Older versions saved the global toggle as ai_experiments_enabled.

The existing upgrade routine intended to migrate old experiment settings, but the global option used the wrong names. As a result, after upgrading from AI Experiments 0.5.0 to the current AI plugin, the global Enable AI setting could appear disabled even though it had been enabled before the upgrade.

How?

  • Migrates ai_experiments_enabled to the current wpai_features_enabled option.
  • Keeps support for the singular typo option names created by earlier upgrade logic.
  • Repairs the global enabled option before version checks, so already-upgraded sites can recover too.
  • Avoids overwriting wpai_features_enabled if the current option already exists.
  • Updates upgrade tests for both fresh legacy upgrades and already-upgraded repair cases.

Testing Instructions

Automated checks run locally:

npm run test:php
npm run lint:php
npm run lint:php:stan

Manual verification:

  1. Install AI Experiments 0.5.0.
  2. Go to Settings > AI Experiments.
  3. Enable experiments.
  4. Upgrade to this branch.
  5. Go to Settings > AI.
  6. Confirm Enable AI remains enabled.

Screenshots/Screencast

Before: AI Experiments 0.5.0 has experiments enabled.
Migration Issue before

After: Current AI settings preserve the global enabled state after upgrade.
Migration Issue after

Use of AI Tools

AI assistance: Yes
Tool(s): ChatGPT / Codex
Used for: Repository review, reproduction planning, implementation guidance, test updates, and local verification. I reviewed the changes, tested the behavior locally, and take responsibility for the final submission.

Open WordPress Playground Preview

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

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>
Co-authored-by: dkotter <dkotter@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 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.20%. Comparing base (841b3da) to head (169dea7).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #586      +/-   ##
=============================================
+ Coverage      72.24%   73.20%   +0.96%     
- Complexity      1162     1529     +367     
=============================================
  Files             68       77       +9     
  Lines           5609     6878    +1269     
=============================================
+ Hits            4052     5035     +983     
- Misses          1557     1843     +286     
Flag Coverage Δ
unit 73.20% <100.00%> (+0.96%) ⬆️

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.

Comment thread includes/Admin/Upgrades.php Outdated
@dkotter dkotter added this to the 1.0.0 milestone May 19, 2026
@dkotter dkotter mentioned this pull request May 19, 2026
42 tasks
@dkotter dkotter merged commit 8e1eea5 into WordPress:develop May 19, 2026
20 checks passed
@ekamran ekamran deleted the shifteq/fix-global-toggle-upgrade-migration branch May 19, 2026 21:22
simison pushed a commit to simison/ai that referenced this pull request May 25, 2026
Fixed - Ensure global AI enabled options are migrated properly

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