[wp-trac] [WordPress Trac] #50146: Blocks: `serialize_block()` doesn't support `WP_Block_Parser_Block`

WordPress Trac noreply at wordpress.org
Mon May 11 18:18:45 UTC 2020


#50146: Blocks: `serialize_block()` doesn't support `WP_Block_Parser_Block`
--------------------------+------------------------------
 Reporter:  dlh           |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Editor        |     Version:  5.3.1
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by aduth):

 If I recall correctly, the implementation was based on the fact that
 `WP_Block_Parser::parse` claims to return type `WP_Block_Parser_Block[]`,
 when in fact it returns an array of arrays.

 Which isn't to say this change request isn't justified, and likely
 correct, but the full extent of the problem permeates beyond just this one
 function.

 Aside: Possibly related: #49926

 > Note: [https://developer.wordpress.org/reference/functions/render_block/
 `render_block`] and `serialize_block` currently receive `$block` in the
 parsed array form. While I
 [https://github.com/WordPress/gutenberg/pull/21467#issuecomment-614202405
 remarked differently] on the original pull request, I don't know that
 these actually need to change, since it seems rather sensible that these
 would except to receive blocks in their parsed forms. If one has access to
 a `WP_Block` instance and needs to create its rendered representation, the
 instance's `render` function can be used directly.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50146#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list