[wp-trac] [WordPress Trac] #45312: parse_blocks return non-existing empty blocks

WordPress Trac noreply at wordpress.org
Thu Nov 8 13:18:51 UTC 2018


#45312: parse_blocks return non-existing empty blocks
--------------------------+-----------------------------
 Reporter:  Chouby        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Editor        |    Version:  5.0
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Create a new post with 2 paragraphs. I created them in visual mode, but
 here is the content of the code mode:
 {{{
 <!-- wp:paragraph -->
 <p>First paragraph</p>
 <!-- /wp:paragraph -->

 <!-- wp:paragraph -->
 <p>Second paragraph</p>
 <!-- /wp:paragraph -->
 }}}

 When I apply `parse_blocks()` on this content, the function returns 3
 blocks. It inserts an empty non existing block between the 2 existing
 paragraph blocks. Here the output:

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

             [innerBlocks] => Array
                 (
                 )

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

         )

     [1] => Array
         (
             [blockName] =>
             [attrs] => Array
                 (
                 )

             [innerBlocks] => Array
                 (
                 )

             [innerHTML] =>


         )

     [2] => Array
         (
             [blockName] => core/paragraph
             [attrs] => stdClass Object
                 (
                 )

             [innerBlocks] => Array
                 (
                 )

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

         )

 )
 }}}

 This is the smallest test case I could create. But if you have n blocks,
 the function returns something like 2n-1 blocks.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45312>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list