Open
Reported for: WPML Multilingual CMS 4.7.4
Overview of the issue
After updating WPML, a critical error may occur on some WooCommerce product pages when Elementor and String Translation plugins are active. This issue is triggered by the Elementor integration in WPML when it tries to serialize null
data, resulting in a fatal 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 ...
Workaround
Please, make sure of having a full site backup of your site before proceeding.
- Open the …/wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/Hooks/QueryFilter.php file.
- Look for line 28.
- Replace:
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; }
- With:
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; }
Our developers are already working on a new release to patch this issue.