Resolved
Reported for: WPML Multilingual CMS 4.5.10
Resolved in: WPML 4.6.4
Overview of the issue
If you import some demo content that requires Elementor (coming from Astra or Real Homes themes, for example), you will notice that it won’t be possible to translate it, and there would be the following error in PHP 8:
Fatal error: Uncaught TypeError: json_decode(): Argument #1 ($json) must be of type string, array given in …/wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/DataConvert.php:22
This happens because the demo content is serialized data, and our integration code expects a JSON encoded string.
Workaround
Please, be sure of making a full backup of your site before proceeding.
- Edit the …/wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/DataConvert.php file.
- Look for line 21.
- Change:
public static function unserialize( $data ) { return json_decode( is_array( $data ) ? $data[0] : $data, true ); }
To:
public static function unserialize( $data ) { $data = is_array( $data ) ? $data[0] : $data; if (is_string($data)) { return json_decode( $data, true ); } return $data; }
Hi
We have added the file but it does not seam to work.
Just getting the same error message.
I’m sorry to hear that it is not working for you. Could you please open a chat in our support to investigate your case?
Regards