Skip to content

Commit

Permalink
Parser: Fix default PHP parser to cast inner blocks as arrays
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dmsnell committed Nov 9, 2018
1 parent 4338dcf commit 052c689
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/block-serialization-default-parser/parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down

0 comments on commit 052c689

Please sign in to comment.