Changeset 60435
- Timestamp:
- 07/08/2025 09:00:01 AM (6 months ago)
- Location:
- branches/6.8
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/wp-includes/blocks.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/6.8
- Property svn:mergeinfo changed
/trunk merged: 60316,60400,60402
- Property svn:mergeinfo changed
-
branches/6.8/src/wp-includes/blocks.php
r60434 r60435 2405 2405 */ 2406 2406 function do_blocks( $content ) { 2407 $blocks = parse_blocks( $content ); 2408 $output = ''; 2409 2410 foreach ( $blocks as $block ) { 2411 $output .= render_block( $block ); 2407 $blocks = parse_blocks( $content ); 2408 $top_level_block_count = count( $blocks ); 2409 $output = ''; 2410 2411 /** 2412 * Parsed blocks consist of a list of top-level blocks. Those top-level 2413 * blocks may themselves contain nested inner blocks. However, every 2414 * top-level block is rendered independently, meaning there are no data 2415 * dependencies between them. 2416 * 2417 * Ideally, therefore, the parser would only need to parse one complete 2418 * top-level block at a time, render it, and move on. Unfortunately, this 2419 * is not possible with {@see \parse_blocks()} because it must parse the 2420 * entire given document at once. 2421 * 2422 * While the current implementation prevents this optimization, it’s still 2423 * possible to reduce the peak memory use when calls to `render_block()` 2424 * on those top-level blocks are memory-heavy (which many of them are). 2425 * By setting each parsed block to `NULL` after rendering it, any memory 2426 * allocated during the render will be freed and reused for the next block. 2427 * Before making this change, that memory was retained and would lead to 2428 * out-of-memory crashes for certain posts that now run with this change. 2429 */ 2430 for ( $i = 0; $i < $top_level_block_count; $i++ ) { 2431 $output .= render_block( $blocks[ $i ] ); 2432 $blocks[ $i ] = null; 2412 2433 } 2413 2434
Note: See TracChangeset
for help on using the changeset viewer.