23408 fix ai consent related classes in the old ai folder structure#23410
Merged
leonidasmi merged 5 commits intoJul 1, 2026
Merged
Conversation
Coverage Report for CI Build 0Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage decreased (-0.3%) to 53.509%Details
Uncovered Changes
Coverage Regressions324 previously-covered lines in 14 files lost coverage.
Coverage Stats💛 - Coveralls |
18 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Mirrors recent AI consent/authorization refactor behavior into the legacy src/ai-* folder structure to keep compatibility working when Free is updated but Premium is still on an older version.
Changes:
- Switched stale-token cleanup to go through the access/refresh token repositories (via
clear_tokens) in both the new and legacyToken_Manager. - Added explicit “user not found” handling in the legacy
AI_ConsentConsent_Handler. - Updated a unit test to expect repository-based token deletion when callback URLs change.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/Unit/AI/Authorization/Application/Token_Manager/Callback_Url_Change_Test.php |
Updates expectations to match repository-based token deletion when callback URLs are stale. |
src/ai/authorization/application/token-manager.php |
Uses clear_tokens() (repository-based) instead of direct user meta deletion and adjusts docblocks. |
src/ai-consent/application/consent-handler.php |
Adds/aligns legacy consent handler behavior to throw when the WP user cannot be resolved. |
src/ai-authorization/application/token-manager.php |
Introduces clear_tokens() in the legacy token manager and uses it for token invalidation and stale-token cleanup. |
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.
Context
Yoast\WP\SEO\AI_Consent\Application\Consent_HandlerandYoast\WP\SEO\AI_Authorization\Application\Token_Managerclasses. Thee old classes are used in case the use has an old version of Yoast SEO Premium and a recent version of Yoast.Summary
This PR can be summarized in the following changelog entry:
Yoast\WP\SEO\AI\classes in the oldYoast\WP\SEO\AI_*ones.Relevant technical choices:
Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
Test granting consent from the user profile
Users->Profileand grant consentRevoke consentand no errors are shown in the browser console network tabTest revoking consent from the user profile
Users->Profileand revoke consentGrant consentand no errors are shown in the browser console network tabwp_usermetatableVerify that there are no lines where the❌ this fails, that's why we created this PR on top: Revoke consent by invalidating tokens #23425. Same with the below stepmeta_namecolumn is_yoast_wpseo_ai_generator_access_jwtand theuser_idcolumn equals to your logged in user idVerify the same formeta_name = _yoast_wpseo_ai_generator_refresh_jwtTest granting consent from the block editor
Relevant test scenarios
Test instructions for QA when the code is in the RC
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
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.Fixes #23408