summaryrefslogtreecommitdiffstats
path: root/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php5
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;