Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot access offset of type string on string: flexible-content - prepare_field_for_import() #944

Open
aptoptout opened this issue Jan 14, 2025 · 0 comments

Comments

@aptoptout
Copy link

aptoptout commented Jan 14, 2025

Describe the bug
Getting a PHP Fatal error after uploading ACF Pro on a fresh Wordpress 6.7.1 + PHP8.2 install.

PHP Fatal error:
Uncaught TypeError: Cannot access offset of type string on string in /var/www/html/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-flexible-content.php:1467

Stack trace:
#0 /var/www/html/wp-includes/class-wp-hook.php(324): acf_field_flexible_content->prepare_field_for_import(Array)
#1 /var/www/html/wp-includes/plugin.php(256): WP_Hook->apply_filters(Array, Array)
#2 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-hook-functions.php(109): apply_filters_ref_array('acf/prepare_fie...', Array)
#3 /var/www/html/wp-includes/class-wp-hook.php(324): _acf_apply_hook_variations(Array)
#4 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array)
#5 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-field-functions.php(1626): apply_filters('acf/prepare_fie...', Array)
#6 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-field-functions.php(1578): acf_prepare_field_for_import(Array)
#7 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/local-fields.php(404): acf_prepare_fields_for_import(Array)
#8 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/local-fields.php(729): acf_add_local_fields(Array)
#9 /var/www/html/wp-includes/class-wp-hook.php(324): _acf_do_prepare_local_fields(5)
#10 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#11 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#12 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/acf.php(378): do_action('acf/include_fie...', 5)
#13 /var/www/html/wp-includes/class-wp-hook.php(324): ACF->init('')
#14 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#15 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#16 /var/www/html/wp-settings.php(704): do_action('init')
#17 /var/www/html/wp-config.php(139): require_once('/var/www/html/w...')
#18 /var/www/html/wp-load.php(50): require_once('/var/www/html/w...')
#19 /var/www/html/wp-admin/admin.php(34): require_once('/var/www/html/w...')
#20 /var/www/html/wp-admin/plugins.php(10): require_once('/var/www/html/w...')
#21 {main}
  thrown in /var/www/html/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-flexible-content.php on line 1467, referer: http://localhost:8080/wp-admin/update.php?action=upload-plugin

To Reproduce
Steps to reproduce the behavior:

  1. Build docker-container from wordpress:6.7.1-php8.2-apache
  2. Upload ACF-Pro & activate plugin
  3. Refresh page, get window with 'critical error'
  4. Go to docker-container, and see the error log, reading like the log-message above

Expected behavior
A working ACF-Pro with PHP8.2.

I found a working solution using the proposed solution from this issue: add the code below at line 1493 in the file class-acf-field-flexible-content.php, right after the foreach:

if (!is_array($sub_field)) {
    continue;
}

Version Information:

  • WordPress Version 6.71.
  • PHP Version 8.2
  • ACF Version 6.3.11
  • Browser [e.g. chrome 103, safari 17]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant