Skip to content

Editor: Update REST API preloaded paths for 6.8 #8441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

@Mamaduka Mamaduka requested a review from peterwilsoncc March 3, 2025 17:04
@Mamaduka Mamaduka self-assigned this Mar 3, 2025
Copy link

github-actions bot commented Mar 3, 2025

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 mamaduka, joemcgill, audrasjb, peterwilsoncc.

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

@Mamaduka Mamaduka force-pushed the update/editor-rest-api-preloaded-paths branch from 5f6cdf4 to 1b9b6c3 Compare March 3, 2025 17:09
Copy link

github-actions bot commented Mar 3, 2025

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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • 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.

Copy link
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

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

@Mamaduka Left a few comments, but overall this looks right to me. Did a very quick performance check and can confirm that this seems to speed up the initial render of the site editor.

Comment on lines 204 to 205
'/wp/v2/templates/lookup?slug=front-page',
'/wp/v2/templates/lookup?slug=home',
Copy link
Member

Choose a reason for hiding this comment

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

In #7695, these were only preloaded if not in the post context. Is the intention to load them always?

@peterwilsoncc
Copy link
Contributor

@peterwilsoncc, what would be the best way to address it in post _wp_get_site_editor_redirection_url?

Sorry mate, I am a little unclear what you are asking here? Is it regarding the backport of the code you have left out for now? Presuming that's the case, I think it will need to be much the same code as both of the following URLs can be used for editing a page with the ID 2:

The latter is used in the site editor.

@Mamaduka
Copy link
Member Author

Mamaduka commented Mar 4, 2025

Is it regarding the backport of the code you have left out for now?

Sorry, @peterwilsoncc, that was the question.

@Mamaduka Mamaduka force-pushed the update/editor-rest-api-preloaded-paths branch from 1b9b6c3 to 60c1caf Compare March 4, 2025 05:02
@Mamaduka
Copy link
Member Author

Mamaduka commented Mar 4, 2025

This should be ready for final review.

$preload_paths[] = add_query_arg(
'slug',
// @see https://github.com/WordPress/gutenberg/blob/e093fefd041eb6cc4a4e7f67b92ab54fd75c8858/packages/core-data/src/private-selectors.ts#L244-L254
empty( $block_editor_context->post->post_name ) ? 'page' : 'page-' . $post->post_name,
Copy link
Member Author

Choose a reason for hiding this comment

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

@Mamaduka Mamaduka force-pushed the update/editor-rest-api-preloaded-paths branch from bf48f57 to 22329a9 Compare March 5, 2025 10:13
@Mamaduka
Copy link
Member Author

Mamaduka commented Mar 5, 2025

Removed default_template_part_areas and default_template_types query arguments for index prealoding path.

@Mamaduka Mamaduka requested a review from audrasjb March 6, 2025 05:44

if ( ! empty( $_GET['postId'] ) && is_numeric( $_GET['postId'] ) ) {
$context_settings['post'] = get_post( (int) $_GET['postId'] );
} elseif ( isset( $_GET['p'] ) && preg_match( '/^\/page\/(\d+)$/', $_GET['p'], $matches ) ) {
Copy link
Contributor

@audrasjb audrasjb Mar 10, 2025

Choose a reason for hiding this comment

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

@Mamaduka probably not relevant, but just wanted to make it be sure: are we certain that the p query var is safe? Asking as I don't see any escaping here.

Copy link
Member Author

Choose a reason for hiding this comment

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

@audrasjb, that's a good question. I've not really explored that possibility, but I assumed it was safe because the pattern checks for numbers, and then the value is cast to an int below.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's finally casted into an int then we're all good :)

@Mamaduka Mamaduka added the props-bot Adding this label triggers the Props Bot workflow for a PR. label Mar 10, 2025
@github-actions github-actions bot removed the props-bot Adding this label triggers the Props Bot workflow for a PR. label Mar 10, 2025
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 59958
GitHub commit: 7596040

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Mar 10, 2025
@Mamaduka Mamaduka deleted the update/editor-rest-api-preloaded-paths branch March 10, 2025 10:33
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.

4 participants