File tree Expand file tree Collapse file tree 3 files changed +12
-25
lines changed
data/blocks/hooked-block-error Expand file tree Collapse file tree 3 files changed +12
-25
lines changed Original file line number Diff line number Diff line change @@ -522,20 +522,6 @@ public function set_props( $args ) {
522
522
$ args = apply_filters ( 'register_block_type_args ' , $ args , $ this ->name );
523
523
524
524
foreach ( $ args as $ property_name => $ property_value ) {
525
- // Avoid infinite recursion in block hooks (hooking to itself).
526
- if ( 'block_hooks ' === $ property_name ) {
527
- if ( ! is_array ( $ property_value ) ) {
528
- continue ;
529
- }
530
- if ( array_key_exists ( $ this ->name , $ property_value ) ) {
531
- _doing_it_wrong (
532
- __METHOD__ ,
533
- __ ( 'Cannot hook block to itself. ' ),
534
- '6.4.0 '
535
- );
536
- unset( $ property_value [ $ this ->name ] );
537
- }
538
- }
539
525
$ this ->$ property_name = $ property_value ;
540
526
}
541
527
}
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " tests/hooked-block-error" ,
3
+ "description" : " A block that throws an error because it tries to hook a block to itself." ,
4
+ "blockHooks" : {
5
+ "tests/hooked-block-error" : " before" ,
6
+ "tests/other-block" : " after"
7
+ }
8
+ }
Original file line number Diff line number Diff line change @@ -1080,22 +1080,15 @@ public function test_register_block_style_name_without_spaces() {
1080
1080
*
1081
1081
* @covers ::register_block_type
1082
1082
*
1083
- * @expectedIncorrectUsage WP_Block_Type::set_props
1083
+ * @expectedIncorrectUsage register_block_type_from_metadata
1084
1084
*/
1085
1085
public function test_register_block_hooks_targeting_itself () {
1086
- $ block_name = 'tests/block-name ' ;
1087
1086
$ block_type = register_block_type (
1088
- $ block_name ,
1089
- array (
1090
- 'block_hooks ' => array (
1091
- $ block_name => 'first ' ,
1092
- 'tests/other-block ' => 'last ' ,
1093
- ),
1094
- )
1087
+ DIR_TESTDATA . '/blocks/hooked-block-error '
1095
1088
);
1096
1089
1097
- $ this ->assertSameSets (
1098
- array ( 'tests/other-block ' => 'last ' ),
1090
+ $ this ->assertSame (
1091
+ array ( 'tests/other-block ' => 'after ' ),
1099
1092
$ block_type ->block_hooks
1100
1093
);
1101
1094
}
You can’t perform that action at this time.
0 commit comments