Edit Post Preload: Cover remaining bound GET/OPTIONS requests on load#78565
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +57 B (0%) Total Size: 8.04 MB 📦 View Changed
ℹ️ View Unchanged
|
39e2642 to
cf0131d
Compare
Add the post-editor's still-unpreloaded bound (single-resource)
requests to `block_editor_rest_api_preload_paths` and drive matching
resolvers in the kickoff so they cache-hit at boot:
- `GET /wp/v2/templates/lookup?slug=front-page` — driven by
`shouldShowHomepageActions`.
- `GET /wp/v2/users/{author}?context=view&_fields=id,name` — post
author panel.
- `OPTIONS /wp/v2/posts` — collection-level `canUser` probe.
- `GET /wp/v2/taxonomies?context=edit` — small bounded taxonomy list.
Also tighten `getDefaultTemplateId.shouldInvalidate` to ignore the
initial `RECEIVE_ITEMS` for `root/site` (no `persistedEdits` flag) so
the kickoff's own site fetch doesn't wipe the just-resolved template
id.
`per_page=-1` queries (comments, wp_pattern_category) are skipped —
the payload is unbounded.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Ensures the editor is in Visual mode before waiting for `#test_tinymce_id_ifr`. Otherwise, if the user's saved editor-mode preference is "html" (Code) — e.g. leftover from an earlier test in the same shard — the iframe never appears and the wait times out. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4a72f72 to
b018f4a
Compare
|
Flaky tests detected in b018f4a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26296880449
|

What?
Add three preload entries (and matching kickoff resolver kicks) for the post editor:
GET /wp/v2/templates/lookup?slug=front-pageGET /wp/v2/users/{author}?context=view&_fields=id,nameOPTIONS /wp/v2/posts(collection-level)GET /wp/v2/taxonomies?context=editThese were all firing as real network requests post-mount on every post-editor boot, captured in the post-editor preload spec's
requestsassertion. After this PR they cache-hit during the kickoff.Why?
slug=front-page—shouldShowHomepageActionsinpost-actions/actions.jscallsgetDefaultTemplateId({ slug: 'front-page' })to gate homepage-specific actions. The resolver result is shared across surfaces.users/{author}?context=view&_fields=id,name— the post-author panel reads the author display name (id+name).OPTIONS /wp/v2/posts— a collection-levelcanUserprobe (no id) for the current post type.taxonomies?context=edit— read byPostTaxonomiesCheck/PostTaxonomieson document-sidebar render. Thetaxonomyentity is non-paginated (response is an object keyed by slug), small bounded payload.Pagination-unbounded queries (
per_page=-1for comments, wp_pattern_category) are intentionally not preloaded — those would balloon the preload payload. They're tracked separately.How?
lib/compat/wordpress-7.0/preload.php): hookblock_editor_rest_api_preload_pathsfor thecore/edit-postcontext with a post, append the three URLs (usingpost.post_authorfor the user record).packages/edit-post/src/index.js):core.getDefaultTemplateId({ slug: 'front-page' })andcore.canUser('create', { kind: 'postType', name: postType })(consumes the OPTIONS preload).core.getUser(post.author, { context: 'view', _fields: 'id,name' })(needs the post record'sauthorfield).getDefaultTemplateId.shouldInvalidate(packages/core-data/src/resolvers.js) to ignoreRECEIVE_ITEMSwithoutpersistedEdits. The kickoff itself dispatchesRECEIVE_ITEMSforroot/site(initial fetch), which without this guard invalidates the just-resolved front-page template id and forces a post-mount refetch.Test results
test/e2e/specs/preload/post-editor.spec.jsupdated — the three URLs are removed from the post-mountrequestsassertion. Spec passes locally:History
🤖 Generated with Claude Code