Tổng quan về sự cố
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
Sự cố này đã được khắc phục trong Advanced Custom Fields Multilingual 2.2.0. Việc cập nhật giải quyết vấn đề này trên trang web của bạn, vì vậy bạn chỉ cần giải pháp tạm thời này nếu chưa thể cập nhật.
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; }