Support

Account

Home Forums General Issues Illegal offset type in isset or empty

Solving

Illegal offset type in isset or empty

  • I keep getting this error pop up and I’ve been trying to trace is back to the root but everything seems fine.

    The full error looks like:

    Warning: Illegal offset type in isset or empty in advanced-custom-fields-pro\includes\class-acf-data.php on line 94 and 110

    The problem is that it’s testing against an array which turns out to be the value I need returned. If I run a debug backtrace on 110 when passed an array as the name I get it running through the following functions with the following arguments.

    – get_field( ‘my_key’, ‘term_123’ )
    —- My Function Call
    – acf_maybe_get_field( ‘my_key’, ‘term_123’ )
    —- \includes\api\api-template.php LN 27
    – acf_get_meta_field( ‘my_key’, ‘term_123’ )
    —- includes\api\api-template.php LN 177

    This is where the trouble starts, from that point on the passed arguments is an array. So I jump into acf_get_meta_field() and down the rabbit hole I go. I get all the way to acf_get_reference() in acf-value-functions.php LN 18 and here’s the input & output:

    acf_get_reference gets passed my proper $field_name and $post_id ( ‘my_key’, ‘term_123’ ) and it hits acf_get_metadata() with this info and returns the array. All of this seems right.

    The calling function (acf_get_meta_field) expects a $field_key in return though.

    $field_key = acf_get_reference( $key, $post_id );

    And what is returned is an array of values. The array of values then gets passed down to acf_get_field() which as $id. Then it hits the $store->has() conditional and falls apart.

    @param (int|string) $id The field ID, key or name.

    I understand the issue is likely on my end of things but I’m having trouble determining _where_ that disconnect is happening and am reaching out here for insight. This field is a term field and the taxonomy exists on multiple post types with terms assigned to multiple posts of different types.

    Any ideas, things I can try? I don’t mind adding breakpoints to the plugin as they won’t be permanent to try and figure out where the issue is rooted and fix it.

  • This probably has nothing to do with this problem, but i got the exact same error and this pops up as the first result when you look it up.

    If you’re trying to get the values of a field that’s in a group, the way you’re supposed to do that is to call get_field() on the group’s slug, not the nested fields. It will return an assoc. array with all the nested fields in it.

  • Without knowing about the code in the template that is triggering the error there isn’t much that can be done.

    But this

    Illegal offset type

    indicates that the field array is missing the field type being shown.

    How is this field defined?

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Illegal offset type in isset or empty’ is closed to new replies.