Skip Navigation

Resolved by author

Topic Tags: Compatibility

Overview of the issue

Users of the Royal Elementor Addons plugin may encounter a deprecated function error message when operating on newer PHP versions 8.1 and above:

Deprecated: urldecode(): Passing null to parameter #1 ($string) of type string is deprecated in .../wp-includes/post.php on line 5864

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open …/wp-content/plugins/royal-elementor-addons/classes/utilities.php file.
  • Look for line 396.
  • Replace:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    // tmp remove after 2 months
    $templates_loop = new \WP_Query([
        'post_type' => 'wpr_templates',
        'name' => $template,
        'posts_per_page' => 1,
    ]);
     
    if ( ! $templates_loop->have_posts() ) {
        if ( defined('ICL_LANGUAGE_CODE') ) {
            $original_post = get_page_by_path($template, OBJECT, 'wpr_templates');
            if ( $original_post ) {
                $original_post_id = $original_post->ID;
                $language_code = ICL_LANGUAGE_CODE;
             
                $translated_post_id = icl_object_id($original_post_id, 'wpr_templates', false, $language_code);
                 
                if ( $translated_post_id ) {
                    $translated_post = get_post($translated_post_id);
                    $translated_slug = $translated_post->post_name;
                 
                    if ( $translated_slug ) {
                        $template = $translated_slug;
                    } else {
                        $template = null;
                    }
                }
            }
        } else {
            $template = null;
        }
    } else {
        $template = $template;
    }
  • With:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    // Ensure template is not null or empty before querying the database
    // compsupp-7576 fix
    if (!empty($template)) {       
        // tmp remove after 2 months
        $templates_loop = new \WP_Query([
            'post_type' => 'wpr_templates',
            'name' => $template,
            'posts_per_page' => 1,
        ]);
         
        if ( ! $templates_loop->have_posts() ) {
            if ( defined('ICL_LANGUAGE_CODE') ) {
                $original_post = get_page_by_path($template, OBJECT, 'wpr_templates');
                if ( $original_post ) {
                    $original_post_id = $original_post->ID;
                    $language_code = ICL_LANGUAGE_CODE;
                 
                    $translated_post_id = icl_object_id($original_post_id, 'wpr_templates', false, $language_code);
                     
                    if ( $translated_post_id ) {
                        $translated_post = get_post($translated_post_id);
                        $translated_slug = $translated_post->post_name;
                     
                        if ( $translated_slug ) {
                            $template = $translated_slug;
                        } else {
                            $template = null;
                        }
                    }
                }
            } else {
                $template = null;
            }
        } else {
            $template = $template;
        }
     
    } // compsupp-7576 fix