summaryrefslogtreecommitdiffstats
path: root/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-19 12:16:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-19 12:16:54 +0000
commitc790e928a86aaeed6bae63d80c583554ce8e3b7c (patch)
tree41a9fd929e2e1c6c833c00b8be762b68053e77f4 /wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
parentAdding upstream version 6.5.2+dfsg1. (diff)
downloadwordpress-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.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;