Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Robert

Fatal TypeError in the ACF addon when a group sub field is false

Opening column settings for a custom post type list screen fatals in the ACF addon.

Admin Columns Pro 7.1.6
Page: wp-admin → Settings → Admin Columns, list screen “dog”
Request: admin-ajax.php?action=ac-list-screen-settings&list_key=dog
Site: https://www.windyknollgoldens.com/

[b]Error[/b]

[code]
Uncaught TypeError: ACA\ACF\FieldRepository::create_group_field(): Argument #1 ($field) must be of type array, false given, called in .../addons/acf/classes/FieldRepository.php on line 150 and defined in .../addons/acf/classes/FieldRepository.php:156
[/code]

The settings request dies while the ACF column factory loads fields for that list screen. The public site is unaffected.

[b]Cause[/b]

create_group_fields() loops $group_field[‘sub_fields’] and passes each item to create_group_field(), which requires an array:

[code]
foreach ($group_field['sub_fields'] ?? [] as $field) {
if (in_array($field['type'], $exclude, true)) {
continue;
}

$fields[] = $this->create_group_field($field, $group_field);
}
[/code]

One sub field was false. Reading $field[‘type’] on false only warns, so the exclude check does not skip it, and the array type hint fatals.

ACF puts that false there. acf_get_fields() appends whatever acf_get_field() returns, and acf_get_field() returns false when a child cannot be loaded (deleted or trashed sub field, a missing local PHP/JSON field, or an acf/load_field callback). The group field’s load_field() copies that list, false included, into sub_fields.

[b]Fix[/b]

Skip anything that is not a field array before using it:

[code]
foreach ($group_field['sub_fields'] ?? [] as $field) {
if (! is_array($field)) {
continue;
}
// existing type exclude and create_group_field() call
}
[/code]

This is only in the Pro ACF addon (addons/acf/classes/FieldRepository.php). The free plugin does not contain this code.

1 month ago
Robert

My attempt to create bold text and code text in this support request didn’t quite work out. I should have just used these buttons. Sorry about that. Hopefully the request is still easy to understand. Unfortunately, I don’t see a button to edit in anywhere.

1 month ago
Stefan van den Dungen Gronovius
Developer

Hi Robert,

Thank you for the detailed report, and don’t worry about the formatting. Everything was clear and easy to follow, and your analysis was spot on!

You’re absolutely right. An ACF Group field containing false instead of a valid subfield caused the column settings to fail to load. We’ve fixed this by skipping any invalid fields in the list. The fix will be included in our next release, 7.1.8.

You might also be interested in knowing why this happened in the first place. There are two possible explanations:
1. A filter that prevents a subfield from loading. Custom code in your theme or a plugin might prevent ACF from loading certain fields. You could check whether any acf/load_field filters are being used on your site.
2. Outdated cached data. Sometimes, when fields are removed or changed, ACF might still use outdated information stored in the site’s cache. Clearing the object cache could resolve this.
For completeness, a trashed subfield doesn’t appear to be the cause, as ACF normally continues to load trashed fields.

Until version 7.1.8 is released, checking for such filters or clearing the object cache might help get the column settings working again.

Thanks again for taking the time to investigate and share your findings. It’s much appreciated!

3 weeks, 4 days ago
Robert

This was helpful! Thank you!

3 weeks, 4 days ago