Make WordPress Core


Ignore:
Timestamp:
01/22/2026 01:11:50 AM (4 months ago)
Author:
dmsnell
Message:

Blocks: Ensure extract_full_block_and_advance() matches parse_blocks()

The behavior of WP_Block_Processor::extract_full_block_and_advance() should produce an identical output to what parse_blocks() would return on the same substring of input.

Unfortunately, when HTML spans followed inner blocks, they were being omitted in the output parse tree. This was due to an omission in the original code which would look for those blocks before advancing again after calling extract_full_block_and_advance() recursively.

This patch adds the missing check and resolves the discrepancy.

Developed in: https://github.com/WordPress/wordpress-develop/pull/10769
Discussed in: https://core.trac.wordpress.org/ticket/64538

Follow-up to [60939].

Props dmsnell, jonsurrell, jorbin.
Fixes #64537.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-processor.php

    r61452 r61509  
    12961296                $block['innerContent'][] = null;
    12971297            }
     1298
     1299            /*
     1300             * Because the parser has advanced past the closing block token, it
     1301             * may be matched on an HTML span. This needs to be processed before
     1302             * moving on to the next token at the start of the next loop iteration.
     1303             */
     1304            if ( $this->is_html() ) {
     1305                $chunk                   = $this->get_html_content();
     1306                $block['innerHTML']     .= $chunk;
     1307                $block['innerContent'][] = $chunk;
     1308            }
    12981309        }
    12991310
Note: See TracChangeset for help on using the changeset viewer.