Skip to content
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

404 Error on a preloaded route when creating a new template part. #36438

Closed
Hug0-Drelon opened this issue Nov 12, 2021 · 1 comment
Closed

404 Error on a preloaded route when creating a new template part. #36438

Hug0-Drelon opened this issue Nov 12, 2021 · 1 comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing")

Comments

@Hug0-Drelon
Copy link
Contributor

Hug0-Drelon commented Nov 12, 2021

Description

When adding a new template part in the admin screen, with the request https://myblog.local/wp-admin/post-new.php?post_type=wp_template_part, WordPress preloads data here. Then there is a call to the route /wp/v2/template-parts/\d+ with a digit as template part identifier, which is filtered by Gutenberg here.
Then the gutenberg_get_block_template() function is called and returnnull because it expects a string identifier (e.g. twentytwentytwo//header) here. This leads to a 404 error in the previous get_item() function.
Although the template part is already created as auto-draft (thanks to WordPress and the call to get_default_post_to_edit() here).

This shouldn't return an error if we expect that wp_template_part post type works like any others.
Also, it prevents anyone to add query parameters to the https://myblog.local/wp-admin/post-new.php?post_type=wp_template_part request to get any information or to add any default value when a template part is created for instance.

Step-by-step reproduction instructions

  1. Go to Appearance >> Template Parts.
  2. Click on "Add New".
  3. Use a debugger to see what happen here .

Indeed, the problem can't be seen in the interface.

Screenshots, screen recording, code snippet

No response

Environment info

WordPress 5.8.2, Gutenberg 11.8.3, TwentyTwentyTwo theme.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@annezazu annezazu added [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") and removed [Feature] Full Site Editing labels Jul 24, 2023
@jordesign
Copy link
Contributor

As Template Parts are both handled differently, and have a different post type slug now - I'll close this issue as no longer reproducible.

@jordesign jordesign closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing")
4 participants