Skip to content

Commit

Permalink
Guard against empty block context in placeholder state (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriszarate authored Oct 9, 2024
1 parent 12171d4 commit cfa9494
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions inc/Editor/DataBinding/BlockBindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ public static function get_value( array $source_args, WP_Block|array $block ): s
return $fallback_content;
}


$value = self::get_remote_value( $block_context, $source_args );

if ( ! is_string( $value ) ) {
Expand Down Expand Up @@ -241,7 +240,13 @@ public static function loop_block_render_callback( array $attributes, string $co
// context available on the block's context property. However, context for
// children blocks comes from this block's `remoteData` attribtue (see
// block.json#providesContext), so we can access it directly.
$block_context = $attributes['remoteData'];
$block_context = $attributes['remoteData'] ?? [];

// Fallback to the content if we don't have the expected context.
if ( ! isset( $block_context['blockName'] ) || ! isset( $block_context['queryInput'] ) ) {
self::log_error( sprintf( 'Missing block context for block binding %s', self::$context_name ), 'unknown' );
return $content;
}

$loop_template = $block->parsed_block['innerBlocks'];
$loop_template_content = $block->parsed_block['innerContent'];
Expand Down

0 comments on commit cfa9494

Please sign in to comment.