Skip to content

Commit

Permalink
Merge branch 'fix/230-block-type-tests-failing' into release/v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbahl committed Jul 24, 2024
2 parents 017831b + c5f43cd commit 827cb7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 10 additions & 4 deletions src/FieldConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ public function resolve_field( $root, array $args, AppContext $context, ResolveI
return $pre_value;
}

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


// resolve block field
if ( is_array( $node ) && isset( $node['blockName'] ) && isset( $node['attrs'] ) ) {
$block = acf_prepare_block( $node['attrs'] );
if ( is_array( $node ) && isset( $node['blockName'], $node['attrs'] ) ) {
$block = $node['attrs'];

// Ensure the block has an ID
if ( ! isset( $block['id'] ) ) {
$block['id'] = uniqid( 'block_', true );
}

$block = acf_prepare_block( $block );
$block_id = acf_get_block_id( $node['attrs'] );
$block_id = acf_ensure_block_id_prefix( $block_id );

acf_setup_meta( $block['data'], $block_id, true );

$return_value = $this->get_field( $field_config['name'], $parent_field_name, $block_id, $should_format_value );
Expand Down
8 changes: 4 additions & 4 deletions tests/_support/WPUnit/AcfFieldTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@ interfaces {
],
]);

codecept_debug([
'$content' => $content,
'$parsed_blocks' => parse_blocks( $content ),
]);
// codecept_debug([
// '$content' => $content,
// '$parsed_blocks' => parse_blocks( $content ),
// ]);

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

0 comments on commit 827cb7f

Please sign in to comment.