• Resolved samvrgl

    (@samvrgl)


    Hi there,

    After updating to version 3.51.2, my sites admin panel immediately crashed with a critical error. I diagnosed the issue via the PHP error logs and found that the plugin is attempting to call wp_rand() before WordPress has loaded the pluggable functions.

    PHP Fatal error:  Uncaught Error: Call to undefined function wp_rand() in /wp-content/plugins/custom-css-js/includes/admin-screens.php:1417
    Stack trace:
    #0 /includes/admin-screens.php(1483): CustomCSSandJS_Admin->build_search_tree()
    #1 /includes/admin-screens.php(90): CustomCSSandJS_Admin->update_custom_codes_for_block_editor()
    #2 /includes/admin-screens.php(36): CustomCSSandJS_Admin->add_functions()
    #3 /includes/admin-screens.php(1796): CustomCSSandJS_Admin->__construct()

    The Issue: It appears that build_search_tree() is being triggered via the constructor chain (__construct -> add_functions -> update_custom_codes_for_block_editor).

    Because the main plugin instance is initialized directly in custom-css-js.php, this code executes before WordPress has loaded pluggable.php (where wp_rand is defined).

    The Temporary Fix: I was able to restore my admin panel by manually editing /includes/admin-screens.php on line 1417 and replacing wp_rand() with the native PHP rand().

    // 3.51.2 code causing crash:
    // $filename .= '?v=' . wp_rand( 1, 10000 );

    // Working fix:
    $filename .= '?v=' . rand( 1, 10000 );

    Could you please patch this in the next release?

    Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Support Diana Burduja

    (@dianaburduja)

    Hello @samvrgl,

    thank you for reporting the issue..

    I was unable to replicate the error on my test website, despite trying multiple different scenarios.

    Some WordPress hosting companies modify the loading order of resources in order to improve performance and reduce loading times, as part of advanced caching and optimization strategies. It could be that the error shows up under certain conditions related to the modified resource order loading.

    In the 3.51.3 version the wp_rand function call was replaced with the PHP native rand, as per your suggestion, so hopefully that doesn’t trigger the error also under your website’s conditions.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.