Skip to content

Commit 827cb7f

Browse files
committed
Merge branch 'fix/230-block-type-tests-failing' into release/v2.4.0
2 parents 017831b + c5f43cd commit 827cb7f

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/FieldConfig.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ public function resolve_field( $root, array $args, AppContext $context, ResolveI
436436
return $pre_value;
437437
}
438438

439-
$parent_field = null;
440439
$parent_field_name = null;
441440
if ( ! empty( $field_config['parent'] ) ) {
442441
$parent_field = acf_get_field( $field_config['parent'] );
@@ -445,12 +444,19 @@ public function resolve_field( $root, array $args, AppContext $context, ResolveI
445444
}
446445
}
447446

448-
449447
// resolve block field
450-
if ( is_array( $node ) && isset( $node['blockName'] ) && isset( $node['attrs'] ) ) {
451-
$block = acf_prepare_block( $node['attrs'] );
448+
if ( is_array( $node ) && isset( $node['blockName'], $node['attrs'] ) ) {
449+
$block = $node['attrs'];
450+
451+
// Ensure the block has an ID
452+
if ( ! isset( $block['id'] ) ) {
453+
$block['id'] = uniqid( 'block_', true );
454+
}
455+
456+
$block = acf_prepare_block( $block );
452457
$block_id = acf_get_block_id( $node['attrs'] );
453458
$block_id = acf_ensure_block_id_prefix( $block_id );
459+
454460
acf_setup_meta( $block['data'], $block_id, true );
455461

456462
$return_value = $this->get_field( $field_config['name'], $parent_field_name, $block_id, $should_format_value );

tests/_support/WPUnit/AcfFieldTestCase.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ interfaces {
414414
],
415415
]);
416416

417-
codecept_debug([
418-
'$content' => $content,
419-
'$parsed_blocks' => parse_blocks( $content ),
420-
]);
417+
// codecept_debug([
418+
// '$content' => $content,
419+
// '$parsed_blocks' => parse_blocks( $content ),
420+
// ]);
421421

422422
// assert the data is returned as expected
423423
self::assertQuerySuccessful( $actual, [

0 commit comments

Comments
 (0)