Skip to content

feat(myyoast-client): add wp yoast auth reset command and clear-state action#23277

Merged
pls78 merged 3 commits into
release/27.7from
DE/reset-client
May 20, 2026
Merged

feat(myyoast-client): add wp yoast auth reset command and clear-state action#23277
pls78 merged 3 commits into
release/27.7from
DE/reset-client

Conversation

@diedexx
Copy link
Copy Markdown
Member

@diedexx diedexx commented May 19, 2026

Context

The MyYoast OAuth client already wipes its full local state (registered client, site/user tokens, key pairs, OIDC/JWKS/DPoP caches) on plugin uninstall via MyYoast_Client_Cleanup::execute(). The same cleanup is useful during development — switching MyYoast environments, recovering from a broken handshake, or letting the Yoast test helper offer a "Clear OAuth state" button — but until now it could only be reached by uninstalling the plugin.

This PR opens two ergonomic entry points on top of that existing service:

  1. A public WordPress action wpseo_myyoast_clear_client_state that runs the same cleanup handler.
  2. A wp yoast auth reset WP-CLI subcommand alongside the existing wp yoast auth {status,register,verify,deregister,authorize,revoke,rotate-keys} family.

Both reuse MyYoast_Client_Cleanup::execute(), so the CLI command, the dev-tooling action, and the uninstall hook all go through one cleanup path.

Summary

This PR can be summarized in the following changelog entry:

  • Adds a wp yoast auth reset WP-CLI command that wipes all MyYoast OAuth client state on the current site.
  • Adds an internal wpseo_myyoast_clear_client_state action that triggers the same cleanup without uninstalling the plugin (fired by the test helper plugin).

Relevant technical choices:

  • The wpseo_myyoast_clear_client_state action is marked @internal — it exists for Yoast development tooling, not as a long-term public extension point.
  • It's an action to decouple the intended use (test helper plugin) from the implementation. The alternative would be to add the reset to the facade, and have a hard dependency on the facade through DI in the test helper.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  1. In wp-config.php, add define( 'YOAST_SEO_MYYOAST_CONNECTION', true );.
  2. From the plugin folder, run wp yoast auth register to register the site as an OAuth client.
  3. Run wp yoast auth status and confirm registered: yes, a client_id, and (optionally) a site/user token.
  4. Run wp yoast auth reset — confirm that a prompt appears asking to wipe all MyYoast OAuth client state.
  5. Type y to confirm and verify the success message: MyYoast OAuth client state cleared..
  6. Run wp yoast auth status again and confirm registered: no, client_id: -, and site_token: none.
  7. Repeat from step 2, then run wp yoast auth reset --yes and verify the command runs without a prompt.
  8. Repeat from step 2 again. In wp shell (or any PHP context inside WP), run do_action( 'wpseo_myyoast_clear_client_state' ); and verify the same cleanup happens.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • The test hepler's Clear OAuth State button

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.
  • This PR also affects Yoast SEO for Google Docs. I have added a changelog entry starting with [yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached the Google Docs Add-on label to this PR.

Documentation

  • [] I have written documentation for this change.

diedexx and others added 2 commits May 19, 2026 13:35
…for state reset

Adds a public WordPress action that runs the same MyYoast_Client_Cleanup::execute()
handler as the uninstall hook, so development tooling (e.g. yoast-test-helper) can
wipe local OAuth state without uninstalling the plugin.

Marked @internal — the action is for the test helper's "Clear OAuth state" button,
not a long-term public extension point.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds a reset subcommand to the existing wp yoast auth command that performs
the same cleanup as plugin uninstall: best-effort server-side deregistration,
followed by deletion of all site/user tokens, registered client credentials,
key pairs, and OIDC/JWKS/DPoP caches. Reuses MyYoast_Client_Cleanup so the
CLI, uninstall, and the wpseo_myyoast_clear_client_state action all share
one cleanup path. Confirms before running; --yes bypasses the prompt.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@diedexx diedexx added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label May 19, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented May 19, 2026

Coverage Report for CI Build 738408

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage decreased (-0.6%) to 53.342%

Details

  • Coverage decreased (-0.6%) from the base build.
  • Patch coverage: 5 uncovered changes across 1 file (1 of 6 lines covered, 16.67%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/myyoast-client/user-interface/auth-command.php 5 0 0.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 67408
Covered Lines: 35851
Line Coverage: 53.19%
Relevant Branches: 16485
Covered Branches: 8899
Branch Coverage: 53.98%
Branches in Coverage %: Yes
Coverage Strength: 44625.3 hits per line

💛 - Coveralls

@diedexx
Copy link
Copy Markdown
Member Author

diedexx commented May 20, 2026

marking fbr, because the test helper 1.19 depends on this

@tatasha2004 tatasha2004 added this to the 27.7 milestone May 20, 2026
@pls78 pls78 self-assigned this May 20, 2026
Comment thread src/myyoast-client/user-interface/myyoast-cleanup-integration.php Outdated
Copy link
Copy Markdown
Member

@pls78 pls78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR && Acc: ✅

@pls78 pls78 merged commit 87e9957 into release/27.7 May 20, 2026
26 checks passed
@pls78 pls78 deleted the DE/reset-client branch May 20, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog fix-before-release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants