refactor(ai): deprecate legacy ai-* modules in Free#23227
Open
thijsoo wants to merge 3 commits into
Open
Conversation
Move the five `ai-*` folders from `src/` to `src/deprecated/src/` and decorate every class with `@deprecated 27.7` + `@codeCoverageIgnore` plus a `_deprecated_function()` call in each method body. The `src/deprecated/` directory is excluded from the Symfony loader, so these classes no longer self-register as integrations or routes; the new `src/ai/` tree is now the only active AI module in Free. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Remove `New_Premium_Or_Free_AI_Conditional` from the `get_conditionals()` return of every active integration and route under `src/ai/` and update the matching unit tests. With the legacy `ai-*` tree deprecated, the version gate has no remaining purpose: the new code is the only AI implementation in Free, so it should load whenever the other AI conditionals (e.g. `AI_Conditional`, `AI_Editor_Conditional`) are met. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Move `Old_Premium_AI_Conditional` and `New_Premium_Or_Free_AI_Conditional` to `src/deprecated/src/conditionals/`, decorate them with the standard `@deprecated 27.7` + `_deprecated_function()` pattern, and register both in `deprecated-classes.php` so any external caller resolving them via the DI container also gets a Symfony deprecation notice. Their unit tests are removed because no active code references them anymore. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Coverage Report for CI Build 67351Coverage increased (+0.5%) to 53.437%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Contributor
Author
|
/build-zip |
|
📦 Plugin zip built successfully! Download it from the workflow run. |
pls78
requested changes
May 8, 2026
Member
pls78
left a comment
There was a problem hiding this comment.
When using the AI features through the UI all is fine, but if I try the REST endpoints I get some unexpected behavior:
1 . https://programmes-hay-eleven-dig.trycloudflare.com/wp-json/yoast/v1/ai/free_sparks is reachable even without the consent granted
2. https://programmes-hay-eleven-dig.trycloudflare.com/wp-json/yoast/v1/ai_generator/get_suggestions returns 403 and not 401
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.
Only merge 3 releases after premium 27.7 is released. So 28.0 for premium.
Context
src/ai/tree (canonical, namespacesYoast\WP\SEO\AI\…) and the legacysrc/ai-*tree (namespacesYoast\WP\SEO\AI_*\…) that existed only to support Premium versions older than 27.5-RC0.Summary
This PR can be summarized in the following changelog entry:
src/ai-*AI modules and theOld_Premium_AI_Conditional/New_Premium_Or_Free_AI_Conditionalgating helpers in favour of the reorganizedsrc/ai/modules.Relevant technical choices:
New_Premium_Or_Free_AI_Conditionalfrom theget_conditionals()of every active integration/route undersrc/ai/. With the legacy tree gone, the version gate no longer has a purpose: the new code is the only AI implementation and should load whenever the feature-level conditionals (AI_Conditional,AI_Editor_Conditional) are met.Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
/wp-json/yoast/v1/ai_generator/get_suggestions,/wp-json/yoast/v1/ai_generator/consent, and/wp-json/yoast/v1/ai/free_sparksfrom the browser; expect a 401 (or REST cookie rejection) for unauthenticated requests rather than 404 — confirms the new routes still register.WP_DEBUG_LOGenabled, exercise the editor flow and confirmwp-content/debug.logdoes not contain any_deprecated_functionnotices originating from the AI flows during normal use — they should only fire if something explicitly calls a legacy class.Relevant test scenarios
Test instructions for QA when the code is in the RC
QA can test this PR by following these steps:
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
src/ai/tree.Yoast\WP\SEO\AI_*\…classes or resolvedOld_Premium_AI_Conditional/New_Premium_Or_Free_AI_Conditionalfrom the DI container will now see PHP deprecation notices but will continue to work.Other environments
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.[yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached theGoogle Docs Add-onlabel to this PR.Documentation
Quality assurance
grunt build:imagesand committed the results, if my PR introduces or edits images or SVGs.Innovation
innovationlabel.