From 4b097901f942e2b2b33c9af6094b9f8ecd864aff Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Wed, 15 Dec 2021 17:48:51 +0100 Subject: [PATCH] When deleting, make sure we're not deleting a fallback template --- .../wordpress-5.9/class-gutenberg-rest-templates-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compat/wordpress-5.9/class-gutenberg-rest-templates-controller.php b/lib/compat/wordpress-5.9/class-gutenberg-rest-templates-controller.php index d909ffd2526254..0e173aaee384ac 100644 --- a/lib/compat/wordpress-5.9/class-gutenberg-rest-templates-controller.php +++ b/lib/compat/wordpress-5.9/class-gutenberg-rest-templates-controller.php @@ -333,7 +333,7 @@ public function delete_item_permissions_check( $request ) { */ public function delete_item( $request ) { $template = gutenberg_get_block_template( $request['id'], $this->post_type ); - if ( ! $template ) { + if ( ! $template || $template->id !== $request['id'] ) { // Make sure there is a template for this ID (and not just a fallback one). return new WP_Error( 'rest_template_not_found', __( 'No templates exist with that id.', 'gutenberg' ), array( 'status' => 404 ) ); } if ( 'custom' !== $template->source ) {