diff -r 34716fd837a4 -r be944660c56a wp/wp-includes/blocks/block.php --- a/wp/wp-includes/blocks/block.php Tue Dec 15 15:52:01 2020 +0100 +++ b/wp/wp-includes/blocks/block.php Wed Sep 21 18:19:35 2022 +0200 @@ -13,6 +13,8 @@ * @return string Rendered HTML of the referenced block. */ function render_block_core_block( $attributes ) { + static $seen_refs = array(); + if ( empty( $attributes['ref'] ) ) { return ''; } @@ -22,11 +24,27 @@ return ''; } + if ( isset( $seen_refs[ $attributes['ref'] ] ) ) { + // WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent + // is set in `wp_debug_mode()`. + $is_debug = defined( 'WP_DEBUG' ) && WP_DEBUG && + defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY; + + return $is_debug ? + // translators: Visible only in the front end, this warning takes the place of a faulty block. + __( '[block rendering halted]' ) : + ''; + } + if ( 'publish' !== $reusable_block->post_status || ! empty( $reusable_block->post_password ) ) { return ''; } - return do_blocks( $reusable_block->post_content ); + $seen_refs[ $attributes['ref'] ] = true; + + $result = do_blocks( $reusable_block->post_content ); + unset( $seen_refs[ $attributes['ref'] ] ); + return $result; } /**