- 状态
- 已解决
- 报告针对
- Advanced Custom Fields Multilingual 2.0.5
- 解决于
- Advanced Custom Fields Multilingual 2.1.0
- 相关插件/主题
- Advanced Custom Fields (ACF)
- 主题标签
- Compatibility
问题概述
使用 Advanced Custom Fields 插件时可能会出现以下致命错误。该错误特别在使用 PHP 8 或更高版本时出现:
Fatal error: Uncaught TypeError: Illegal offset type in isset or empty in .../wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-element-translation.php:259
临时解决方法
在继续操作之前,请确保对您的站点进行完整备份。
- 打开 …/wp-content/plugins/acfml/classes/class-wpml-acf-attachments.php 文件。
- 找到第 28 行。
- 替换:
foreach ( $attachments as $key => $attachment_id ) { $translated_attachments[ $key ] = apply_filters( 'wpml_object_id', $attachment_id, 'attachment', true ); - 替换为:
foreach ( $attachments as $key => $attachment_id ) { if (is_int($attachment_id)) { $translated_attachments[ $key ] = apply_filters( 'wpml_object_id', $attachment_id, 'attachment', true ); }