diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-19 12:16:54 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-19 12:16:54 +0000 |
commit | c790e928a86aaeed6bae63d80c583554ce8e3b7c (patch) | |
tree | 41a9fd929e2e1c6c833c00b8be762b68053e77f4 /wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php | |
parent | Adding upstream version 6.5.2+dfsg1. (diff) | |
download | wordpress-c790e928a86aaeed6bae63d80c583554ce8e3b7c.tar.xz wordpress-c790e928a86aaeed6bae63d80c583554ce8e3b7c.zip |
Adding upstream version 6.5.3+dfsg1.upstream/6.5.3+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php index cec8a77..1c2a769 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php @@ -165,7 +165,8 @@ class WP_REST_Templates_Controller extends WP_REST_Controller { array_shift( $hierarchy ); } while ( ! empty( $hierarchy ) && empty( $fallback_template->content ) ); - $response = $this->prepare_item_for_response( $fallback_template, $request ); + // To maintain original behavior, return an empty object rather than a 404 error when no template is found. + $response = $fallback_template ? $this->prepare_item_for_response( $fallback_template, $request ) : new stdClass(); return rest_ensure_response( $response ); } @@ -532,7 +533,7 @@ class WP_REST_Templates_Controller extends WP_REST_Controller { * @since 5.8.0 * * @param WP_REST_Request $request Request object. - * @return stdClass Changes to pass to wp_update_post. + * @return stdClass|WP_Error Changes to pass to wp_update_post. */ protected function prepare_item_for_database( $request ) { $template = $request['id'] ? get_block_template( $request['id'], $this->post_type ) : null; |