diff --git a/includes/blocks.php b/includes/blocks.php index 81a8f967..f3b2a432 100644 --- a/includes/blocks.php +++ b/includes/blocks.php @@ -914,6 +914,7 @@ function ( $block ) { array( 'blockTypes' => array_values( $block_types ), 'postType' => get_post_type(), + 'StrictMode' => true, ) ); @@ -1031,6 +1032,16 @@ function acf_ajax_fetch_block() { $raw_context = $args['context']; $post_id = $args['post_id']; + // Decode query if sent as a JSON string instead of an array. + // The block editor JS may serialize the query parameter as JSON, + // which causes a fatal TypeError on PHP 8.4 when accessing offsets. + if ( is_string( $query ) ) { + $query = json_decode( wp_unslash( $query ), true ); + if ( ! is_array( $query ) ) { + $query = array(); + } + } + // Bail early if no block. if ( ! $block ) { wp_send_json_error();