• Hi,

    Thanks for your theme maintenance.

    Running any WP-CLI doctor check command, i.e.:

    wp doctor check core-update

    I get this error:

    
    PHP Fatal error:  Uncaught TypeError: Return value of weaverx_get_cur_page_id() must be of the type string, null returned in /var/www/clients/client2/web52/web/wp-content/themes/weaver-xtreme/includes/lib-runtime.php:263
    Stack trace:
    #0 /var/www/clients/client2/web52/web/wp-content/themes/weaver-xtreme/functions.php(561): weaverx_get_cur_page_id()
    #1 /var/www/clients/client2/web52/web/wp-includes/class-wp-hook.php(308): weaverx_enqueue_scripts_action()
    #2 /var/www/clients/client2/web52/web/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
    #3 /var/www/clients/client2/web52/web/wp-includes/plugin.php(517): WP_Hook->do_action()
    #4 /var/www/clients/client2/web52/web/wp-includes/script-loader.php(2194): do_action()
    #5 /var/www/clients/client2/web52/web/wp-includes/class-wp-hook.php(308): wp_enqueue_scripts()
    #6 /var/www/clients/client2/web52/web/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
    #7 /var/www/clients/client2/web52/web/wp-includes/plugin.php(517): WP_Hook->do_action()
    #8 /var/www/clients/client2/w in /var/www/clients/client2/web52/web/wp-content/themes/weaver-xtreme/includes/lib-runtime.php on line 263

    Related code is:

    function weaverx_get_cur_page_id(): string
    {
        global $weaverx_cur_page_ID;
    
        return $weaverx_cur_page_ID;
    }

    Checked on PHP versions 7.4 to 8.2.

    I replaced the function in a child theme and this seems to work fine:

    function weaverx_get_cur_page_id(): string
    {
        global $weaverx_cur_page_ID;
    
        // Comprueba si la variable está definida y no es null
        if (isset($weaverx_cur_page_ID) && !is_null($weaverx_cur_page_ID)) {
            return $weaverx_cur_page_ID;
        }
    
        // En caso contrario, devuelve una cadena vacía
        return '';
    }

    Thank you.

  • The topic ‘Null value fatal error running command from WP-CLI’ is closed to new replies.