- 状态
- 已解决
- 报告针对
- WPML Multilingual CMS 4.7.4
- 解决于
- WPML 4.7.5
- 相关插件/主题
- Elementor
- 主题标签
- Compatibility
问题概述
更新 WPML 后,当 Elementor 和字符串翻译插件处于启用状态时,某些 WooCommerce 产品页面上可能会出现严重错误。当 WPML 中的 Elementor 集成尝试序列化 null 数据时会触发此问题,从而导致致命的 TypeError。
PHP Fatal error: Uncaught TypeError: WPML\PB\Elementor\DataConvert::serialize(): Argument #1 ($data) must be of type array,
null given, called in /wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/Hooks/QueryFilter.php on line 34 ...
临时解决方法
在继续操作之前,请确保为您的站点进行完整站点备份。
- 打开 …/wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/Hooks/QueryFilter.php 文件。
- 找到第 28 行。
- 替换:
public function translateQueryIds( $value, $object_id, $meta_key, $single ) { if ( WPML_Elementor_Data_Settings::META_KEY_DATA === $meta_key && $single ) { $value = get_post_meta( $object_id, WPML_Elementor_Data_Settings::META_KEY_DATA, true ); if ( $value ) { $value = DataConvert::unserialize( $value, false ); $value = $this->recursivelyTranslateQueryIds( $value ); $value = DataConvert::serialize( $value, false ); } } return $value; }
- 替换为:
public function translateQueryIds( $value, $object_id, $meta_key, $single ) { if ( WPML_Elementor_Data_Settings::META_KEY_DATA === $meta_key && $single ) { $newValue = get_post_meta( $object_id, WPML_Elementor_Data_Settings::META_KEY_DATA, true ); if ( $newValue ) { $newValue = DataConvert::unserialize( $newValue, false ); if ( is_array( $newValue ) ) { $newValue = $this->recursivelyTranslateQueryIds( $newValue ); return DataConvert::serialize( $newValue, false ); } return $value; } } return $value; }
我们的开发人员已经在开发新版本以修复此问题。