Saltar navegación

Open

Reported for: Advanced Custom Fields Multilingual 2.1.2

Topic Tags: ATE, Bug, Compatibility

Overview of the issue

If you are using Advanced Custom Fields plugin for registering custom post types or custom taxonomies, you may encounter a fatal error in environments using PHP 8 or warnings in PHP 7, when you have corrupted data stored for any of those objects:

PHP Fatal error:  Uncaught TypeError: array_walk(): Argument #1 ($array) must be of type array, null given in .../wp-content/plugins/acfml/classes/Strings/Helper/ContentTypeLabels.php:55

Workaround

Please, make sure of having a full site backup of your site before proceeding.

Option 1

With Advanced Custom Fields Multilingual disabled, edit the problematic ACF post type or taxonomy and set the missing values for the labels or the object slug, and save it. Then activate Advanced Custom Fields Multilingual and it is all good.

Option 2

  • Open …/wp-content/plugins/acfml/classes/Strings/Helper/ContentTypeLabels.php file.
  • Look for line 53.
  • Replace:
    array_walk( $objectArgs['labels'], function( &$value, $key ) use ( $translatedLabels ) {
    	$value = Obj::propOr( $value, $key, $translatedLabels );
    } );
    
  • With:
    $labels = Obj::propOr( [], 'labels', $objectArgs );
    array_walk( $labels, function( $value, $key ) use ( &$objectArgs, $translatedLabels ) {
    	$objectArgs['labels'][ $key ] = Obj::propOr( $value, $key, $translatedLabels );
    } );
    

Deje una respuesta

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

Puede utilizar estas etiquetas:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>