Open rumur opened 4 years ago
Hi @rumur
Thanks for the bug report. Can you please test the following fix? Please edit the file "includes/fields/class-acf-field-checkbox.php" and change line 445 from:
return acf_get_field_type('select')->update_field( $field );
To:
// Decode choices (convert to array).
$field['choices'] = acf_decode_choices( $field['choices'] );
$field['default_value'] = acf_decode_choices( $field['default_value'], true );
return $field;
Hi @elliotcondon
I've tried your snippet and it worked out. I didn't get any E_NOTICE this time.
@elliotcondon not getting it on first attempt... but had it on mult. sites I think so will check.
Not relevant to this issue, just a question.
@elliotcondon after you mentioned acf_deceode_choice
function, I've looked inside of it and noticed one thing at this point https://github.com/AdvancedCustomFields/acf/blob/ddf8837941c7422968aa8ac10ae7cd176ea36482/includes/api/api-helpers.php#L2110
if the passed string is already an array, you bail right away, but what if you've passed $array_keys
as true
, you won't be able to get array keys in this case, because the condition that checks it is placed at the very end.
Is it ok like this?
Hi @rumur. Yes, for our use-case, this is perfectly fine :)
@elliotcondon is there a hotfix coming for this anytime soon ? We have a ton of sites to manage.
Hi @Beee4life
Yes. A new version will be available in the next few days 👍
After applying aforementioned fix, I got this error, when I saved a field group. I just changed a text field (in a repeater) to select (no choices defined, because they'll be added with acf/load_field).
Notice: Undefined index: parent in /var/www/html/web/app/plugins/advanced-custom-fields-pro/includes/admin/admin-field-group.php on line 483
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/web/app/plugins/advanced-custom-fields-pro/includes/admin/admin-field-group.php:483) in /var/www/html/web/wp/wp-includes/pluggable.php on line 1281
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/web/app/plugins/advanced-custom-fields-pro/includes/admin/admin-field-group.php:483) in /var/www/html/web/wp/wp-includes/pluggable.php on line 1284
@Beee4life Can you please confirm which fix you have applied? This new error does not seem related at this stage.
I replaced
return acf_get_field_type('select')->update_field( $field );
with:
// Decode choices (convert to array).
$field['choices'] = acf_decode_choices( $field['choices'] );
$field['default_value'] = acf_decode_choices( $field['default_value'], true );
return $field;
Thanks @Beee4life
This has me completely stumped. I've attempted to replicate the issue, but can't get any kind of PHP error to occur when changing a sub Text field into a Select field. I also can't see how this change to the Checkbox field would affect a Select field.
If it's not too much to ask, can you please spin up a fresh WP site in "Local by Flywheel" and try to replicate the issue? Please keep the default theme active and edit the functions.php file with any extra logic needed.
If you can replicate the issue, please export the site (from flywheel app, right click the site and click "export") and attach to your next reply. I'll import this and get to work replicating / testing the issue :)
I encountered it on a personal project, so it's not too big of a deal...
But if it happens again, I might be able to do you a better one... I can give you read access to the repository I'm using to maintain the site, which has everything (if you know how to start a Docker container). I can also provide SQL if needed but not through GH of course.
Will be working on it a lot in few days, so if it happens I'll pick up on it soon (I think). I'll post it here, when I encounter it again. You know where to reach me (if needed) to get some specific info.
@elliotcondon I just got the error again... the action didn't complete so had to navigate to the field group again and then I saw I got 2 new empty fields.
I removed the fields and saved it again, no probs whatsoever.
I have to say I haven't had this issue once since my last post.
PS running v5.8.12
Hi @Beee4life
Thanks for the update. Are you able to replicate this on a fresh WP install? I wonder if there is something specific with either your theme code, plugins installed or the field group data that is causing the problem. If you are able to narrow down the variables, that would be a great help!
Didn't happen again, so not able yet to replicate.
Hey @elliotcondon
Recently I've updated the ACF PRO from 5.8.9 to 5.8.11 and started to get the E_NOTICE when I'm trying to create a checkbox.
The
$field
is missing amultiple
indexSpecs:
The stack trace of the error is the following:
The Content of that
$field
: