From 052c689a4bd7bdd04a6e2825a02780831a960d2f Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Fri, 9 Nov 2018 10:54:56 -0500 Subject: [PATCH] Parser: Fix default PHP parser to cast inner blocks as arrays Since the introduction of the default parsers we have had a bug in the PHP version whereby inner blocks were being popped onto the output stack as PHP classes instead of as simple associated arrays. Blocks that weren't inner blocks were being properly type-casted as arrays. This patch adds the cast in where it's needed in order to fix this inconsistent behavior. So far this hasn't caused any troubles or exposed itself but while working on other PRs like #11434 it became evident in test code. --- packages/block-serialization-default-parser/parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-serialization-default-parser/parser.php b/packages/block-serialization-default-parser/parser.php index 2211cf0c192260..edda34b571568d 100644 --- a/packages/block-serialization-default-parser/parser.php +++ b/packages/block-serialization-default-parser/parser.php @@ -457,7 +457,7 @@ function add_freeform( $length = null ) { */ function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) { $parent = $this->stack[ count( $this->stack ) - 1 ]; - $parent->block->innerBlocks[] = $block; + $parent->block->innerBlocks[] = (array) $block; $html = substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset ); if ( ! empty( $html ) ) {