WPML
Trạng thái
Đã giải quyết
Được báo cáo cho
Advanced Custom Fields Multilingual 2.0.5
Đã giải quyết trong
Advanced Custom Fields Multilingual 2.2.0
Plugin/giao diện liên quan
Advanced Custom Fields (ACF)
Thẻ chủ đề
Compatibility

Tổng quan về lỗi

Trong một số trường hợp, plugin Advanced Custom Fields Multilingual (ACFML) có thể gặp phải cảnh báo PHP khi sử dụng các trường ACF:

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

Giải pháp tạm thời

Vui lòng đảm bảo bạn đã sao lưu toàn bộ trang web của mình trước khi tiếp tục.


  • Mở tệp …/acfml/classes/class-wpml-acf-repeater-shuffle.php.

  • Tìm dòng 244.

  • Thay thế:
    	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;
    	}

  • Bằng:
    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;
    }

Tất cả các lỗi đã ghi nhận →