• Hello ACF team,

    We are encountering a fatal error on PHP 8+ related to ACF internal data handling.

    Error message:
    Uncaught TypeError: Cannot access offset of type array in isset or empty
    in wp-content/plugins/advanced-custom-fields-pro/includes/class-acf-data.php on line 119

    Environment:

    • WordPress: latest
    • ACF PRO: latest (at time of writing)
    • PHP: 8.x
    • Theme: Custom theme

    This error appears to occur when ACF attempts to access an array offset using a variable that is itself an array. PHP 8+ no longer allows this and throws a fatal TypeError.

    Stack trace points to:
    includes/class-acf-data.php:119

    This may be triggered by:

    • Invalid field keys passed to ACF core
    • Corrupted field data
    • ACF filters receiving unexpected array values

    Suggested fix:
    Add defensive type checking before accessing offsets, e.g.:

    if ( is_string( $key ) || is_int( $key ) ) {
    isset( $array[ $key ] );
    }

    or otherwise guard against array keys before using isset()/empty().

Viewing 1 replies (of 1 total)
  • Plugin Support ACF Support

    (@acfsupport)

    Hi @mabfahad,

    Thanks for the detailed report and stack trace.

    You are spot on with your analysis, this error almost always occurs when a custom function or filter passes an Array (instead of a String or Integer) as the $selector or $post_id argument to an ACF function like get_field() or get_value(). While previous PHP versions handled this loosely, PHP 8 throws a fatal error immediately when an illegal offset type is used.

    Since this forum is generally for user-to-user assistance, please create a ticket using our ​support form so that we can help you investigate and implement this further.

    Best regards,
    Pat

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.