Skip to content

Editor: Preload bound single-resource GETs the post editor would otherwise fetch post-mount#11948

Open
ellatrix wants to merge 1 commit into
WordPress:trunkfrom
ellatrix:try/preload-post-editor-bound-gets
Open

Editor: Preload bound single-resource GETs the post editor would otherwise fetch post-mount#11948
ellatrix wants to merge 1 commit into
WordPress:trunkfrom
ellatrix:try/preload-post-editor-bound-gets

Conversation

@ellatrix
Copy link
Copy Markdown
Member

What?

Adds four entries to \$preload_paths in wp-admin/edit-form-blocks.php:

  • /wp/v2/templates/lookup?slug=front-page
  • /wp/v2/taxonomies?context=edit
  • OPTIONS for the current post-type collection (via rest_get_route_for_post_type_items( \$post_type ))
  • /wp/v2/users/{author}?context=view&_fields=id,name

Why?

Each of these is captured today as a post-mount network fetch by Gutenberg's post-editor preload e2e spec — the editor fires them on first mount but they aren't currently preloaded server-side. Adding them to \$preload_paths lets the kickoff consume the data from the inline cache and removes the network round-trip from the boot path.

The corresponding callers:

  • templates/lookup?slug=front-pageshouldShowHomepageActions in post-actions/actions.js calls getDefaultTemplateId({ slug: 'front-page' }) while computing actions for the current post. (It also gates getHomePage for sites with show_on_front !== 'page'.)
  • taxonomies?context=editPostTaxonomiesCheck / PostTaxonomies read the registered taxonomy list. The endpoint is non-paginated (response is an object keyed by slug), small bounded payload.
  • OPTIONS /wp/v2/posts (or whichever post-type) — collection-level canUser probe for the current post type.
  • users/{author}?context=view&_fields=id,name — the post-author panel reads the author display name.

per_page=-1 queries (comments, wp_pattern_category) are intentionally not preloaded — those payloads are unbounded.

Gutenberg counterpart

WordPress/gutenberg#78565

Trac ticket

(to be filed)

Testing

After this change, the Gutenberg post-editor preload spec (test/e2e/specs/preload/post-editor.spec.js) asserts that none of these four URLs fire as post-mount network requests anymore — they cache-hit from the preload payload.

…rwise fetch post-mount.

Adds four entries to `\$preload_paths` in `wp-admin/edit-form-blocks.php`:

* `/wp/v2/templates/lookup?slug=front-page` — used by the editor's
  homepage actions gate (`shouldShowHomepageActions`).
* `/wp/v2/taxonomies?context=edit` — read by the post-taxonomies
  sidebar panel; non-paginated endpoint with a small bounded payload.
* `OPTIONS` for the current post-type collection — collection-level
  permission probe.
* `/wp/v2/users/{author}?context=view&_fields=id,name` — read by the
  post-author panel.

Each of these is captured today as a post-mount network fetch by
Gutenberg's post-editor preload e2e spec; preloading them eliminates
those requests from the boot path.
@github-actions
Copy link
Copy Markdown

Trac Ticket Missing

This pull request is missing a link to a Trac ticket. For a contribution to be considered, there must be a corresponding ticket in Trac.

To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in the Core Handbook.

@github-actions
Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props ellatrix.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant