From c7bb6d62150226b187afbac827b1886a7238f4de Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Fri, 16 Nov 2018 17:41:58 -0500 Subject: [PATCH] REST API: Assign default for block renderer attributes Previously we would pass `NULL` to `render`. While `render` provides a default `array()` value, since an explicit value is provided, it would not take effect. With this change, the endpoint assures a default value to be provided as a parameter to get the `get_item` callback that is compatible with the function signature of `WP_BlockType::render`. Alternatively, it could be considered to have separate invocations of `render`, depending on whether the request parameter is set. --- lib/class-wp-rest-block-renderer-controller.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/class-wp-rest-block-renderer-controller.php b/lib/class-wp-rest-block-renderer-controller.php index 3ecf25de449301..b9839f080376a2 100644 --- a/lib/class-wp-rest-block-renderer-controller.php +++ b/lib/class-wp-rest-block-renderer-controller.php @@ -59,6 +59,7 @@ public function register_routes() { 'type' => 'object', 'additionalProperties' => false, 'properties' => $block_type->get_attributes(), + 'default' => array(), ), 'post_id' => array( 'description' => __( 'ID of the post context.', 'gutenberg' ),