Fatal error on PHP 8: Cannot access array offset in class-acf-data.php line 119
-
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 119Environment:
- 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:119This 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().
You must be logged in to reply to this topic.