[wp-trac] [WordPress Trac] #64482: Twenty Twenty-One: Efficiency refactor of excerpt-generation with Block Processor.

WordPress Trac noreply at wordpress.org
Wed Jan 7 22:21:23 UTC 2026


#64482: Twenty Twenty-One: Efficiency refactor of excerpt-generation with Block
Processor.
---------------------------+-----------------------------
 Reporter:  dmsnell        |      Owner:  (none)
     Type:  enhancement    |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Bundled Theme  |    Version:  trunk
 Severity:  normal         |   Keywords:  has-patch
  Focuses:                 |
---------------------------+-----------------------------
 Refactors `twenty_twenty_one_print_first_instance_of_block()` to rely on
 `WP_Block_Processor` where available. This brings an uplift in efficiency
 in two separate ways:
  - The Block Parser only needs to parse as far into a document as it needs
 to read, and lazily parses block attributes. This can result in a dramatic
 reduction in memory overhead as long posts do not need to be fully parsed
 and temporarily stored in memory, just to be ignored.
  - By doing less work the Block Processor is able to stop its processing
 and move on, while `parse_blocks()` has to pause the world while it builds
 the full block tree.

 This is not supposed to change any existing behavior, though it does
 rearrange some of the code from the legacy approach to harmonize with the
 logic in the refactor. While separate functions in the refactor would be
 more testable, this function lacks testing and the combined logic may be
 simpler to maintain over time. Given that the minimum supported WordPress
 version will remain at 5.6, the check for the existence of the class will
 have to stay, and grouping common logic in a single function will be less
 effort than maintaining those potential changes across two functions.

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


More information about the wp-trac mailing list