Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#45316 closed defect (bug) (reported-upstream)

parse_blocks returns an empty object in 'attrs' when there are no attributes

Reported by: Chouby Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.0
Component: Editor Keywords:
Focuses: Cc:


According to the inline documentation of WP_Block_Parser, parse_blocks should return arrays not objects, all attributes are arrays. See https://core.trac.wordpress.org/browser/branches/5.0/src/wp-includes/class-wp-block-parser.php#L124


<!-- wp:paragraph -->
<p>First paragraph</p>
<!-- /wp:paragraph -->


    [0] => Array
            [blockName] => core/paragraph
            [attrs] => stdClass Object

            [innerBlocks] => Array

            [innerHTML] => 
<p>First paragraph</p>



If the block has no attribute, [attrs] is an empty object while, according to the documentation, we would expect an empty array.

In other cases, when the block includes attributes or when parsing a free form text, [attrs] is, as expected, an array.

Change History (3)

#1 @swissspidy
2 years ago

Looks like there‘s an open PR for this: https://github.com/WordPress/gutenberg/pull/11434

#2 @matveb
2 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Closing as this was addressed upstream.

#3 @ocean90
2 years ago

  • Milestone Awaiting Review deleted
  • Resolution changed from fixed to reported-upstream
Note: See TracTickets for help on using tickets.