Probe direct host for editor capability detection on Atomic sites#22883
Open
jkmassel wants to merge 1 commit into
Open
Probe direct host for editor capability detection on Atomic sites#22883jkmassel wants to merge 1 commit into
jkmassel wants to merge 1 commit into
Conversation
Collaborator
Generated by 🚫 Danger |
Contributor
|
|
Contributor
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #22883 +/- ##
=======================================
Coverage 37.34% 37.34%
=======================================
Files 2320 2320
Lines 124653 124663 +10
Branches 16941 16943 +2
=======================================
+ Hits 46549 46558 +9
- Misses 74339 74340 +1
Partials 3765 3765 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
41f8a18 to
0577e91
Compare
Fixes #22879. EditorSettingsRepository.fetchRouteSupport queried the WP.com proxy via getWpApiClient, but GutenbergView fetches wp-block-editor/v1/settings from the direct host. On Atomic sites without an application password those hosts can disagree, so the proxy would advertise the route, capability detection would say "theme styles supported," and the editor would then 404 trying to load it.
0577e91 to
591dcd1
Compare
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.


Description
Fixes #22879. The editor stalls partway through preloading on WP.com Atomic sites whose direct host doesn't expose
wp-block-editor/v1/settings, because capability detection reports "theme styles supported" via the WP.com proxy and then the editor 404s fetching that route from the direct host.Root cause
EditorSettingsRepository.fetchRouteSupportandGutenbergViewwere not talking to the same host on Atomic sites:WpApiClientProvider.getWpApiClient(site)returns the WP.com client wheneversite.isWPCom || site.isUsingWpComRestApi, soapiRoot()is queried viapublic-api.wordpress.com. Its route list driveshasRouteForEndpoint("/wp-block-editor/v1", "settings", ...).GutenbergViewuses the configuredsiteURL(the direct host) for its block-editor settings fetch, notsiteApiRoot.For Atomic sites those two hosts can diverge — the proxy advertises routes the direct host doesn't expose — and we confidently tell the editor "theme styles is supported" right before the editor 404s on the direct host.
Fix
Detect against the host the editor will actually use. For all WP.com Atomic sites, run REST API autodiscovery on
site.urland read the routes list off the discovery result directly. Non-Atomic shapes keep the existinggetWpApiClient/getApiUrlResolverpath.WpApiClientProvider: NewurlResolverFor(apiRootUrl: ParsedUrl)— a thin wrapper aroundWpOrgSiteApiUrlResolverso callers can reuse theParsedUrlreturned by discovery without coupling to uniffi internals.EditorSettingsRepository: Takes a newWpLoginClientdependency.fetchRouteSupportbranches onsite.isWPComAtomic: that branch callswpLoginClient.apiDiscovery(site.url)and usesapiRootUrl+apiDetailsfrom the success result — no secondapiRoot().get()needed. Non-Atomic shapes route throughfetchRouteSupportViaConfiguredClient, which is the original logic untouched.Discovery is used rather than an unauthenticated
apiRoot().get()against${site.url}/wp-jsonso we don't bake in an assumption about where the REST API lives (custom permalink structures or non-default REST API paths would break that).What we explored
site.url, so we don't assume the API lives at/wp-json. Matches the project intent of talking directly to the site whenever possible.siteApiRootforwp-block-editor/v1/settings. Library-side change, and the project intent ("direct to the site as much as possible") cuts the other way.Scope
Covers all WP.com Atomic sites — with or without an application password — because the editor talks to the direct host in both shapes. Atomic + app password didn't reproduce #22879 (Basic auth on the direct host exposes the route anyway), but the symmetric fix avoids surprises later. Non-Atomic shapes (Simple, self-hosted, JPC) keep the existing detection path unchanged.
Testing instructions
Atomic site:
Simple Site test (regression check):
Unit tests:
./gradlew :WordPress:testJetpackDebugUnitTest --tests EditorSettingsRepositoryTest— passes (existing tests + new tests covering Atomic direct-host discovery).