From 596e76ed99fcaeb321b78e57e267002ae6ba5506 Mon Sep 17 00:00:00 2001 From: dmsnell Date: Tue, 17 Mar 2026 16:50:47 +0000 Subject: [PATCH] REST API: Add missing properties in block node arrays. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There have been a few places in WordPress where a method creates “an array representation simulating the output of parse_blocks”, but the array is missing one or more keys. The missing keys cause issue with downstream code, which either treats a block without, for example, `innerBlocks` as invalid input, or more commonly, assumes that `innerBlocks` is present and accesses it unconditionally. This can even lead to crashes. This patch adds the missing properties so that the code behaves as expected. Since the array values are empty by default, adding these missing keys does not present any intentional behavioral changes — only a safer default. Developed in: https://github.com/WordPress/wordpress-develop/pull/10735 Discussed in: https://core.trac.wordpress.org/ticket/64505 Follow-up to [47360], [57354]. Props dlh, dmsnell, mukesh27, westonruter. Fixes #64505. Built from https://develop.svn.wordpress.org/trunk@62039 git-svn-id: http://core.svn.wordpress.org/trunk@61321 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/blocks.php | 1 + .../endpoints/class-wp-rest-block-renderer-controller.php | 1 + wp-includes/version.php | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index 89007d0d0d..170d7c0fbf 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -971,6 +971,7 @@ function insert_hooked_blocks( &$parsed_anchor_block, $relative_position, $hooke 'blockName' => $hooked_block_type, 'attrs' => array(), 'innerBlocks' => array(), + 'innerHTML' => '', 'innerContent' => array(), ); diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php index 3e4e8eb794..de7e147c38 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php @@ -181,6 +181,7 @@ class WP_REST_Block_Renderer_Controller extends WP_REST_Controller { $block = array( 'blockName' => $request['name'], 'attrs' => $attributes, + 'innerBlocks' => array(), 'innerHTML' => '', 'innerContent' => array(), ); diff --git a/wp-includes/version.php b/wp-includes/version.php index d0f92d13d2..24b64a499b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '7.0-beta5-62038'; +$wp_version = '7.0-beta5-62039'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.