[wp-trac] [WordPress Trac] #56519: Inner blocks serialization bug in serialize_block function

WordPress Trac noreply at wordpress.org
Sun Jan 25 12:23:15 UTC 2026


#56519: Inner blocks serialization bug in serialize_block function
-----------------------------------------+------------------------------
 Reporter:  saqibsarwar                  |       Owner:  (none)
     Type:  defect (bug)                 |      Status:  new
 Priority:  normal                       |   Milestone:  Awaiting Review
Component:  Editor                       |     Version:  5.3.1
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch reporter-feedback  |     Focuses:
-----------------------------------------+------------------------------
Changes (by ozgursar):

 * keywords:  has-patch needs-testing => has-patch reporter-feedback


Comment:

 == Reproduction Report

 === Environment
 - WordPress: 7.0-alpha-61215-src
 - PHP: 8.2.29
 - Server: nginx/1.29.4
 - Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
 - Browser: Chrome 144.0.0.0
 - OS: macOS
 - Theme: Twenty Twenty-Five 1.4
 - MU Plugins: None activated
 - Plugins:
   * Code Snippets 3.9.4
   * Test Reports 1.2.1

 === Steps taken
 1. Add the following snippet via Code Snippets plugin or `functions.php`
 to test the `serialize_block()` function


 {{{
 add_action( 'init', function() {
     if ( isset( $_GET['reproduce_bug'] ) ) {

         echo "<h1>Reproduce Inner Blocks Serialization Bug</h1>";

         // Create a block with 3 inner blocks
         $test_block = array(
             'blockName' => 'core/group',
             'attrs' => array(),
             'innerBlocks' => array(
                 array(
                     'blockName' => 'core/paragraph',
                     'attrs' => array(),
                     'innerBlocks' => array(),
                     'innerHTML' => '<p>First</p>',
                     'innerContent' => array( '<p>First</p>' ),
                 ),
                 array(
                     'blockName' => 'core/paragraph',
                     'attrs' => array(),
                     'innerBlocks' => array(),
                     'innerHTML' => '<p>Second</p>',
                     'innerContent' => array( '<p>Second</p>' ),
                 ),
                 array(
                     'blockName' => 'core/paragraph',
                     'attrs' => array(),
                     'innerBlocks' => array(),
                     'innerHTML' => '<p>Third</p>',
                     'innerContent' => array( '<p>Third</p>' ),
                 ),
             ),
             'innerHTML' => '<div class="wp-block-group"></div>',
             'innerContent' => array(
                 '<div class="wp-block-group">',
                 null,
                 null,
                 null,
                 '</div>',
             ),
         );

         echo "<h2>Test Case:</h2>";
         echo "<p>Group block with 3 inner paragraph blocks</p>";
         echo "<p>innerContent has 3 null placeholders</p>";

         echo "<h2>Calling Core serialize_block():</h2>";
         $result = serialize_block( $test_block );

         echo "<pre>" . htmlspecialchars( $result ) . "</pre>";

         echo "<h2>Bug Check:</h2>";

         $first_count = substr_count( $result, 'First' );
         $second_count = substr_count( $result, 'Second' );
         $third_count = substr_count( $result, 'Third' );
         $para_count = substr_count( $result, 'wp:paragraph' ) / 2;

         echo "<table border='1'>";
         echo "<tr><th>Expected</th><th>Actual</th><th>Status</th></tr>";
         echo "<tr><td>3 paragraphs total</td><td>{$para_count}
 paragraphs</td><td>" . ($para_count == 3 ? '✓' : '✗ BUG') . "</td></tr>";
         echo "<tr><td>'First' appears 1x</td><td>{$first_count}
 times</td><td>" . ($first_count == 1 ? '✓' : '✗ BUG') . "</td></tr>";
         echo "<tr><td>'Second' appears 1x</td><td>{$second_count}
 times</td><td>" . ($second_count == 1 ? '✓' : '✗ BUG') . "</td></tr>";
         echo "<tr><td>'Third' appears 1x</td><td>{$third_count}
 times</td><td>" . ($third_count == 1 ? '✓' : '✗ BUG') . "</td></tr>";
         echo "</table>";

         if ( $para_count > 3 || $first_count > 1 || $second_count > 1 ||
 $third_count > 1 ) {
             echo "<h2 style='color:red;'>✗ BUG CONFIRMED: Content is
 duplicated!</h2>";
             echo "<p>The serialize_block() function is duplicating inner
 blocks.</p>";
         } else {
             echo "<h2 style='color:green;'>✓ Bug NOT present in this
 WordPress version</h2>";
             echo "<p>The issue appears to be already fixed.</p>";
         }

         exit;
     }
 });
 }}}


 2. Visit http://localhost:8889/?reproduce_bug=1
 3. ❌ Bug is not occurring

 === Expected behavior
 - Ticket reports `serialize_block()` fails when the number of inner blocks
 increases.

 === Screenshots/Screencast with results
 [[Image(https://i.imgur.com/U4jyvdJ.png)]]

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


More information about the wp-trac mailing list