-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Update regex to handle 404 template slug #37579
Conversation
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @PatelUtkarsh! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much @PatelUtkarsh, great spot! Nice job on the fix -- LGTM!
One note: The affected file (templates REST API controller) is part of the WP 5.9 compatibility layer. This means two things:
- If you're using a test setup (like wp-env) locally, it's possible that you're using the latest WP Core development version, in which case templates REST API controller will be used from WP Core rather than Gutenberg. In this case, you'll need to force using Gutenberg's in order to test this PR. This can be done e.g. with the following patch:
diff --git a/lib/compat/wordpress-5.9/template-parts.php b/lib/compat/wordpress-5.9/template-parts.php
index 102c9275be..6b9b8bc00a 100644
--- a/lib/compat/wordpress-5.9/template-parts.php
+++ b/lib/compat/wordpress-5.9/template-parts.php
@@ -13,7 +13,7 @@
// Only run any of the code in this file if the version is less than 5.9.
// wp_list_users was introduced in 5.9.
-if ( ! function_exists( 'wp_list_users' ) ) {
+if ( true || ! function_exists( 'wp_list_users' ) ) {
/**
* Registers block editor 'wp_template_part' post type.
*/
diff --git a/lib/compat/wordpress-5.9/templates.php b/lib/compat/wordpress-5.9/templates.php
index d5bdf1c55c..c0aa2a2e03 100644
--- a/lib/compat/wordpress-5.9/templates.php
+++ b/lib/compat/wordpress-5.9/templates.php
@@ -13,7 +13,7 @@
// Only run any of the code in this file if the version is less than 5.9.
// wp_list_users was introduced in 5.9.
-if ( ! function_exists( 'wp_list_users' ) ) {
+if ( true || ! function_exists( 'wp_list_users' ) ) {
/**
* Registers block editor 'wp_template' post type.
*/
- Furthermore, this means that we'll need to backport the fix to WP Core. I'll add the relevant label.
I'll file a backport PR. |
|
Congratulations on your first merged pull request, @PatelUtkarsh! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts: https://profiles.wordpress.org/me/profile/edit/ And if you don't have a WordPress.org account, you can create one on this page: https://login.wordpress.org/register Kudos! |
Description
Adding 404 template from
/wp-admin/site-editor.php?postType=wp_template
causes 400 withrest_invalid_pattern
How has this been tested?
/wp-admin/site-editor.php?postType=wp_template
Screenshots
Bug:
adding-404-template.mp4
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).