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

Update regex to handle 404 template slug #37579

Merged
merged 1 commit into from
Dec 23, 2021

Conversation

PatelUtkarsh
Copy link
Contributor

@PatelUtkarsh PatelUtkarsh commented Dec 22, 2021

Description

Adding 404 template from /wp-admin/site-editor.php?postType=wp_template causes 400 with rest_invalid_pattern

How has this been tested?

  • Theme without 404 templates.
  • Open /wp-admin/site-editor.php?postType=wp_template
  • Add new 404 templates.
  • Used nightly WordPress build to test this.

Screenshots

Bug:

adding-404-template.mp4

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Dec 22, 2021
@github-actions
Copy link

👋 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.

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended Core REST API Task Task for Core REST API efforts labels Dec 22, 2021
Copy link
Contributor

@ockham ockham left a 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! :shipit:

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.

@ockham ockham added the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Dec 22, 2021
@ockham
Copy link
Contributor

ockham commented Dec 22, 2021

I'll file a backport PR.

@ockham
Copy link
Contributor

ockham commented Dec 22, 2021

I'll file a backport PR.

WordPress/wordpress-develop#2077

@ockham ockham merged commit 1b571a9 into WordPress:trunk Dec 23, 2021
@github-actions
Copy link

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!

@github-actions github-actions bot added this to the Gutenberg 12.3 milestone Dec 23, 2021
@noisysocks noisysocks removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jan 4, 2022
noisysocks added a commit to noisysocks/wordpress-develop that referenced this pull request Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core REST API Task Task for Core REST API efforts First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants