Open astacreative opened 3 years ago
I see this error in the Oxygen Editor, not in the front end
@astacreative @Jehu
Do you know the steps needed to cause this error to occur?
Have the same problem since yesterday's update to 3.9 beta, but I'm not sure if it didn't occur with 3.8. I can reproduce the error if I create a relation field in ACF, assign one or more posts in this relation field to a post and output this relation field via Dynamic Data in Oxygen.
Sorry @s-gundlach, I don't seem to be able to reproduce it when adding a Relationship field to Oxygen via dynamic data in a Text element.
@KittenCodes Actually the error in this case is caused by something else. I've done several tests and managed to find the cause. Additionally to my previously mentioned reproduction steps do the following: The error only occurs if in any ACF Field Group a field of the type "Group" is added. It does not matter in which ACF Field Group and for which post type this Field Group is used - it happens in every case. Within this group add any other Field (Text e.g.). Now the error should occur.
Edit: I have done some additional tests on a blank install and wondered why the error does not occur there. So I deleted everything in the template on my Live Site step by step. Another condition for the error to occur is the Oxygen Comments List Element. If the Oxygen Comments List Element is positioned before the ACF Dynamic Data, the error will be occur.
@s-gundlach Awesome, thanks. I've updated our internal bug report.
Working Hotfix for this one in 3.9 Beta:
File: /wp-content/plugins/oxygen/component-framework/includes/acf/oxygen-acf-integration.php
Modify function is_settings_page_feild in lines 916-933 Before
function is_settings_page_feild( $group_id ) {
$is_settings_page = false;
$field_group = acf_get_field_group( $group_id );
foreach ($field_group['location'] as $location_type) {
foreach ($location_type as $location) {
if ($location['param'] == "options_page") {
$is_settings_page = true;
break;
}
}
}
return $is_settings_page;
}
After
function is_settings_page_feild( $group_id ) {
$is_settings_page = false;
$field_group = acf_get_field_group( $group_id );
if($field_group){
foreach ($field_group['location'] as $location_type) {
foreach ($location_type as $location) {
if ($location['param'] == "options_page") {
$is_settings_page = true;
break;
}
}
}
}
return $is_settings_page;
}
The error occurs if acf_get_field_group($group_id) returns false. After that there is no check if $field_group has a valid value. By adding the if statement the error can be avoided.
Edit: However, I was still wondering why the error only occurs or is displayed when the Comments List element is placed in front of the affected block. The explanation is that in the Comments List element (/wp-content/plugins/oxygen/component-framework/components/classes/comments-list.class.php) in line 86 the display of errors is defined:
ini_set('display_errors', 1);
@s-gundlach Thank you - I've passed this onto our developers.
In Oxygen 4.0 beta 1 the function was changed similar to @s-gundlach approach above, but the issue is persistent. The hotfix still resolves the issue:
function in 4.0 beta 1
function is_settings_page_feild( $group_id ) {
$is_settings_page = false;
$field_group = acf_get_field_group( $group_id );
if (is_array($field_group['location'])) {
foreach ($field_group['location'] as $location_type) {
foreach ($location_type as $location) {
if ($location['param'] == "options_page") {
$is_settings_page = true;
break;
}
}
}
}
return $is_settings_page;
}
}
Reducing the if statement to if ($field_group) {
works.
Issue is present in 4.0 and first bug was reported on #1818 but still didn't get fixed. Doing a simple $field_group && is_array($field_group['location'])
fixes this issue
The issue is still present in Oxygen 4.6. I have a ACF file
field which turns false
when no file is set. When I use a condition to check if it's there or not, I get the same error message on line 745 and 746.
had the same issue and we got it working by adding "?? null" to lines that were the issue. In our case they were lines 715, 745, 746
Basically before: $image_url = wp_get_attachment_image_src( $image_id, $image_size )[0];
after $image_url = wp_get_attachment_image_src( $image_id, $image_size )[0] ?? null;
Hope this helps some.
This error is showing so many times in the front end:
Warning: Invalid argument supplied for foreach() in /home/u91/domains/example.com/public_html/dev/wp-content/plugins/oxygen/component-framework/includes/acf/oxygen-acf-integration.php on line 914