ナビゲーションをスキップする

Open

Reported for: Advanced Custom Fields Multilingual 2.0.5

Topic Tags: Compatibility

Overview of the issue

Under some scenarios, Advanced Custom Fields Multilingual (ACFML) plugin may run into a PHP warning when utilizing ACF fields:

Attempt to read property "post_content" on null in plugins .../acfml/classes/class-wpml-acf-repeater-shuffle.php on line 249

Workaround

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

  • Open …/acfml/classes/class-wpml-acf-repeater-shuffle.php file.
  • Look for line 244.
  • Replace:
    	private function isChildOfRepeaterField( $key, $postId ) {
    		$acfFieldObject = get_field_object( $key, $postId );
    		if ( isset( $acfFieldObject['parent'] )
    			 && $acfFieldObject['parent'] > 0 ) {
    			$fieldParent        = get_post( $acfFieldObject['parent'] );
    			$fieldParentContent = maybe_unserialize( $fieldParent->post_content );
    			if ( isset( $fieldParentContent['type'] ) && 'repeater' === $fieldParentContent['type'] ) {
    				return true;
    			}
    		}
    		return false;
    	}
    
  • With:
    private function isChildOfRepeaterField( $key, $postId ) {
        $acfFieldObject = get_field_object( $key, $postId );
        if ( isset( $acfFieldObject['parent'] ) ) {
            if ( is_numeric( $acfFieldObject['parent'] ) && $acfFieldObject['parent'] > 0 ) {
                $fieldParent = get_post( $acfFieldObject['parent'], $postId );
                if ( $fieldParent ) {
                    $fieldParentContent = maybe_unserialize( $fieldParent->post_content );
                    if ( isset( $fieldParentContent['type'] ) && 'repeater' === $fieldParentContent['type'] ) {
                        return true;
                    }
                }
            } elseif ( is_string( $acfFieldObject['parent'] ) ) {
                $fieldParent = get_field_object( $acfFieldObject['parent'], $postId );
                if ( isset( $fieldParent['type'] ) && 'repeater' === $fieldParent['type'] ) {
                    return true;
                }
            }
        }
        return false;
    }
    

2 返答 へ “Advanced Custom Fields Multilingual (ACFML): PHP Warning - Attempt to read property "post_content" on null”

    • Yes, this issue is in our devs roadmap. We will keep this page updated and let you know once it is fixed.

返答する

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.

これらのタグを使用できます:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>