Skip Navigation

Resolved

Reported for: WPML Multilingual CMS 4.5.10

Resolved in: WPML 4.6.4

Topic Tags: Bug, Compatibility

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.

  1. Edit the …/wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/DataConvert.php file.
  2. Look for line 21.
  3. 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;
    }
    

2 תגובות אל “Elementor & PHP 8 - Fatal error: Uncaught TypeError: json_decode()”