Opened 2 years ago
Closed 2 years ago
#55648 closed enhancement (fixed)
Correct serialize_block @param documentation according to what the function does
Reported by: | manooweb | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 6.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | has-patch assigned-for-commit commit |
Focuses: | docs | Cc: |
Description
It looks like the documentation of serialize_block() function doesn't corresponding on what the function really expects.
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/blocks.php#L598
Indeed, documentation says we must provide a WP_Block_Parser_Block object while serialize_block() function tries to access to an array.
See for example
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/blocks.php#L605
or
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/blocks.php#L606
As serialize_blocks() function uses serialize_block() function the proposed patched also fixed serialize_blocks() function documentation.
In addition, we often need to parse blocks before serialize them like in _inject_theme_attribute_in_block_template_content() function https://core.trac.wordpress.org/browser/trunk/src/wp-includes/block-template-utils.php#L435
It also seems parse_blocks() using the default WP_Block_Parser returns representative array of WP_Block_Parser_Block object by casting object to array.
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/blocks.php#L912
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-block-parser.php#L312
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-block-parser.php#L495
Hi @manooweb and thanks for spotting this.
The patch looks good to me. Self assigning for final review and commit consideration.