Make WordPress Core

Opened 6 years ago

Closed 4 years ago

#51708 closed defect (bug) (duplicate)

Editor: Block render filters are not called on nested blocks

Reported by: noisysocks Owned by:
Priority: normal Milestone:
Component: Editor Version:
Severity: normal Keywords: needs-patch
Cc: Focuses:

Description

First reported here: ​https://github.com/WordPress/gutenberg/issues/25900

pre_render_block, render_block_data and render_block_context are only called for top-level blocks which isn't what you would expect from reading those filters' documentation and likely causes unexpected bugs e.g. that the Latest Posts block does not have its attributes migrated.

We should be applying these filters inside WP_Block::_construct as well.

To test, add these filters and then open a post that has some blocks inside a Group block. Note that the filters aren't called for the inner blocks.

<?php
add_filter(
        'pre_render_block',
        function( $pre_render, $parsed_block ) {
                var_dump( 'pre_render_block', $pre_render, $parsed_block );
        },
        10,
        2
);

add_filter(
        'render_block_data',
        function( $parsed_block, $source_block ) {
                var_dump( 'render_block_data', $parsed_block, $source_block );
        },
        10,
        2
);

add_filter(
        'render_block_context',
        function( $context, $parsed_block ) {
                var_dump( 'render_block_context', $context, $parsed_block );
        },
        10,
        2
);

Change History (4)

#1 @noisysocks
6 years ago

cc. @gziolo

#2 @noisysocks
6 years ago

  • Milestone 5.7
  • Resolution → duplicate
  • Status new → closed

Oops, this was already ticketed: #51612

#3 @scruffian
4 years ago

  • Resolution duplicate
  • Status closed → reopened

This was never fixed and the Gutenberg issue is also closed so I think this should be reopened.

#4 @scruffian
4 years ago

  • Resolution → duplicate
  • Status reopened → closed

Duplicate of #51612.

oh wait I missed https://core.trac.wordpress.org/ticket/51612, sorry.

Note: See TracTickets for help on using tickets.