Remove dead WPCOM app authorization GET flow#3579
Conversation
`fetchWPComAppAuthorizationUrl` lost its only caller when EnableNewProductSyncButton was removed (60e15f4), leaving the JS action and the entire PHP chain it triggered (GET /rest-api/authorize -> AuthController::get_authorize_callback -> OAuthService::get_auth_url -> get_data_from_google -> Middleware::get_sdi_auth_params/ get_sdi_auth_endpoint) unreachable. Removes the action, the GET route handler and its exclusive dependents, and their tests, while leaving the route's still-live DELETE/PUT handlers untouched. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3579 +/- ##
===========================================
- Coverage 66.8% 66.5% -0.3%
+ Complexity 5342 5308 -34
===========================================
Files 914 912 -2
Lines 28280 28027 -253
Branches 1720 1718 -2
===========================================
- Hits 18883 18631 -252
+ Misses 9136 9135 -1
Partials 261 261
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Both remaining AuthController handlers are dead: revoking a WPCOM OAuth token is no longer valid now that the plugin uses client-credentials auth (INTEGRA-48), and the PUT status-update flow could never succeed since nothing writes the nonce it checks for (removed in the prior GET flow cleanup). Removing both leaves AuthController with no route, so the whole class goes, along with its exclusive dependents: OAuthService::revoke_wpcom_api_auth/deactivate/get_wpcom_api_url, AccountService::update_wpcom_api_authorization/reset_wpcom_api_authorization_data/ delete_wpcom_api_auth_nonce/delete_wpcom_api_status_transient, the GOOGLE_WPCOM_AUTH_NONCE option, the DisconnectController fan-out entry and its JS error special-case, and the useUpdateRestAPIAuthorizeStatusByUrlQuery hook. AccountService::get_connected_status()'s client-credentials health check is untouched. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
joemcgill
left a comment
There was a problem hiding this comment.
🤖 AI Code Review
Issue: Clean Up remaining API Pull Access code
Branch: worktree-remove-dead-wpcom-auth -> develop
Summary
This PR correctly and completely removes all dead code from the defunct WPCOM app authorization GET/DELETE/PUT flow — I verified zero remaining references to any deleted symbol (AuthController, revoke_wpcom_api_auth, update_wpcom_api_authorization, GOOGLE_WPCOM_AUTH_NONCE, etc.) anywhere in the codebase. The still-live paths (get_connected_status(), is_wpcom_api_status_healthy(), the rest of disconnect-all-accounts) are intact. Two cleanup gaps and a latent (pre-existing, not introduced by this PR) status bug are worth a look before merge.
🟡 Suggestions
-
OAuthServiceis still registered as a full DI service (src/Internal/DependencyManagement/CoreServiceProvider.php:195,243-244): Verified — no code in the repo ever fetches anOAuthServiceinstance from the container anymore;AccountServiceonly references its two remaining constants (OAuthService::STATUS_APPROVED/STATUS_ERROR) statically. Theshare_with_tags( OAuthService::class )call and itsPROVIDESentry are dead weight from this same cleanup and should be removed to finish the job. -
WPCOM_REST_API_STATUShas no reset path once it reaches'error', but this predates this PR (src/MerchantCenter/AccountService.php:229-246):get_connected_status()only ever flipsnull → approved → error; nothing in the current codebase (before or after this PR) writes it back to empty. Previously,reset_wpcom_api_authorization_data()could clear it, but that method was only reachable via a successful legacy OAuth-token revoke (revoke_wpcom_api_auth()) — which, per this PR's own round-2 note, already can't succeed under client-credentials auth. So this PR isn't introducing a new regression, just removing code whose reset path was already unreachable. Still, worth flagging as a follow-up (same spirit as the round-1 note about the dead PUT route) since a merchant who ever lands in'error'has no way back to'approved'short of a manual option delete. -
OAuthServiceclass docblock is stale (src/API/WP/OAuthService.php): Still describes "a service to handle WordPress.com OAuth," but the class is now two status constants. Worth a one-line update so future readers don't assume it has active OAuth behavior.
🔵 Nitpicks
- (
src/Hooks/README.md:698): Thewoocommerce_gla_partner_app_auth_failurehook entry is stale — its only trigger site (get_sdi_auth_params()) was deleted in round 1. Carry-over from the prior review round. - (
changelog.txt): No entry for either round's removals. Given the size of this cleanup (a full controller, service, and several AccountService methods), aDev -entry in the next unreleased block is warranted. Carry-over from the prior review round.
This review was generated by Claude. A human review is still required before merging.
Nothing resolves OAuthService from the container anymore since AuthController was deleted; AccountService only reads its two remaining constants statically. Flagged in code review as leftover dead weight from the same cleanup. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Addressed in 41f08c5 |
|
The following feedback came in from @eason9487 in Slack, which I plan to address before merging:
|
Summary
Fixes: GOOWOO-238
Round 1 — dead GET auth-url flow:
fetchWPComAppAuthorizationUrl(js/src/data/actions.js) lost its only caller whenEnableNewProductSyncButtonwas removed in 60e15f4 (2025-08-07). It has had zero callers since./wc/gla/rest-api/authorize->AuthController::get_authorize_callback()->OAuthService::get_auth_url()->get_data_from_google()->Middleware::get_sdi_auth_params()/get_sdi_auth_endpoint().Round 2 — dead DELETE and PUT flow (rest of AuthController):
revoke_wpcom_api_auth) was reachable (disconnect-all-accounts UI + plugin deactivation), but revoking a WPCOM OAuth token is no longer valid now that the plugin uses client-credentials auth (per commit42533bc44, INTEGRA-48).update_wpcom_api_authorization) was wired to a live-looking hook, but could never succeed — it checks a stored nonce that nothing writes anymore (the writer was removed in round 1), so it always threw "No stored nonce found."AuthControllerwith no route to register, so the whole class is deleted, along with everything exclusively feeding it:OAuthService::revoke_wpcom_api_auth/deactivate/get_wpcom_api_url(OAuthService is now a small constants-only class),AccountService::update_wpcom_api_authorization/reset_wpcom_api_authorization_data/delete_wpcom_api_auth_nonce/delete_wpcom_api_status_transient, theGOOGLE_WPCOM_AUTH_NONCEoption, theDisconnectControllerfan-out entry and its JS error special-case, and theuseUpdateRestAPIAuthorizeStatusByUrlQueryhook.Left untouched, confirmed still live:
AccountService::get_connected_status()/is_wpcom_api_status_healthy()/OptionsInterface::WPCOM_REST_API_STATUS— the current client-credentials health-check path.OAuthService::STATUS_APPROVED/STATUS_ERRORconstants — still read byget_connected_status().DisconnectController's other fan-out endpoints.reconnect-wpcom-account/*/ConnectWPComAccountCard— a separate Jetpack site-connection feature, not part of this auth flow.JetpackWPCOM.php— unrelated Jetpack-connection-package compatibility shim.get_sdi_endpoint,get_sdi_merchant_update_endpoint,update_sdi_merchant_account).Test plan
composer run test-unit(or the project's WP test env) —DisconnectControllerTest,AccountServiceTestshould pass;AuthControllerTest,OAuthServiceTestare deletednpm run lint:js/npm run test:js— confirm no lingering references anddisconnectAllAccountstests still pass🤖 Generated with Claude Code