AdvancedCustomFields / acf

Advanced Custom Fields
http://advancedcustomfields.com/
823 stars 168 forks source link

Uncaught TypeError: Cannot access offset of type string on string - flexible content #915

Closed bm-jakob closed 4 weeks ago

bm-jakob commented 4 weeks ago

Describe the bug Currently experiencing errors on many of my sites.

[06-Jun-2024 07:20:56 UTC] PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in /plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-flexible-content.php:898
Stack trace:
#0 /usr/www/users/x/wp-includes/class-wp-hook.php(324): acf_field_flexible_content->validate_value()
#1 /usr/www/users/x/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#2 /usr/www/users/x/wp-content/plugins/advanced-custom-fields-pro/includes/validation.php(335): apply_filters()
#3 /usr/www/users/x/wp-content/plugins/advanced-custom-fields-pro/includes/validation.php(294): acf_validate_value()
#4 /usr/www/users/x/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php(1217): acf_validate_values()
#5 /usr/www/users/x/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php(1193): acf_validate_block_from_post_data()
#6 /usr/www/users/x/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php(950): acf_get_block_validation_state()
#7 /usr/www/users/x/wp-includes/class-wp-hook.php(324): acf_ajax_fetch_block()
#8 /usr/www/users/x/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#9 /usr/www/users/x/wp-includes/plugin.php(517): WP_Hook->do_action()
#10 /usr/www/users/x/wp-admin/admin-ajax.php(192): do_action()
#11 {main}
  thrown in /usr/www/users/x/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-flexible-content.php on line 898

To Reproduce Steps to reproduce the behavior: I'm not sure. All my custom ACF blocks are infinite loading and can't show or let me edit content.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots or Video image

Version Information:

lgladdy commented 4 weeks ago

Hey @bm-jakob,

Sorry about this - we're aware of the bug and are preparing a bug fix release.

For now, you can solve it by either disabling block validation on the block containing flexible content by setting validate: false inside the ACF key of your block JSON, or disabling block validation globally using a filter like:

add_filter(
    'block_type_metadata_settings',
    function ( $settings, $metadata ) {

        if ( ! acf_is_acf_block_json( $metadata ) ) {
            return $settings;
        }

        $settings['validate'] = false;
        return $settings;
    },
    10,
    2
);

Or, given you're on GitHub and probably don't mind editing code, you could manually patch pro/fields/class-acf-field-flexible-content.php at line 896 (so, the first after foreach ( $value as $i => $row ) {)

Adding:

// ensure row is an array
if ( ! is_array( $row ) ) {
        continue;
}
bm-jakob commented 4 weeks ago

Thank you for the fast support @lgladdy! I will use one of the above until a fix is released.

I have quite a few sites, can we expect a hotfix release? Do you have an ETA already?

Thank you again.

lgladdy commented 4 weeks ago

Working with the team on this now... I'll give you an update on the release date as soon as I've got it!

lgladdy commented 4 weeks ago

Hey @bm-jakob! We just released ACF 6.3.1.1, a PRO only release with this fix in.

Thanks for your patience!

@Log1x We probably fixed that bug too in 6.3.1.1, but let me know if not.