Support » Plugin: WP-Cron Status Checker » Fatal error on WP 4.9

  • Resolved Mansi Shah

    (@daredevil22)


    Hi,

    Getting following fatal error on sites with WP v4.9:

    PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function wp_get_ready_cron_jobs() in /wp-content/plugins/wp-cron-status-checker/inc/cron-checker.php:100
    Stack trace:
    #0 /wp-content/plugins/wp-cron-status-checker/inc/cron-checker.php(175): wcsc_monitor_runs()
    #1 /wp-includes/class-wp-hook.php(286): wcsc_init_cron_monitor('')
    #2 /wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
    #3 /wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #4 /wp-settings.php(450): do_action('init')
    #5 /wp-config.php(111): require_once('/...')
    #6 /wp-load.php(37): require_once('/...')
    #7 /wp-cron.php(33): require_once('/...')
    #8 {main}
      thrown in /wp-content/plugins/wp-cron-status-checker/in" while reading response header from upstream

    Works well on sites with WP v5.1+.

    My question, will this plugin not work on lower WP versions?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author webheadcoder

    (@webheadllc)

    Ah sorry about that. I’ll have a fix in the next update. eta: 2 weeks or so. For now you can copy the source code for wp_get_ready_cron_jobs() and paste it into inc/cron-checker.php

    function wp_get_ready_cron_jobs() {
        /**
         * Filter to preflight or hijack retrieving ready cron jobs.
         *
         * Returning an array will short-circuit the normal retrieval of ready
         * cron jobs, causing the function to return the filtered value instead.
         *
         * @since 5.1.0
         *
         * @param null|array $pre Array of ready cron tasks to return instead. Default null
         *                        to continue using results from _get_cron_array().
         */
        $pre = apply_filters( 'pre_get_ready_cron_jobs', null );
        if ( null !== $pre ) {
            return $pre;
        }
     
        $crons = _get_cron_array();
     
        if ( false === $crons ) {
            return array();
        }
     
        $gmt_time = microtime( true );
        $keys     = array_keys( $crons );
        if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) {
            return array();
        }
     
        $results = array();
        foreach ( $crons as $timestamp => $cronhooks ) {
            if ( $timestamp > $gmt_time ) {
                break;
            }
            $results[ $timestamp ] = $cronhooks;
        }
     
        return $results;
    }

    also found here:
    https://developer.wordpress.org/reference/functions/wp_get_ready_cron_jobs/

    When you update to the next version this will be overwritten, but it will also have the fix in it so you won’t have to worry. I’ve ran this plugin on WP v4.9 and it works with this code.

    Plugin Author webheadcoder

    (@webheadllc)

    version 1.2 is out and should fix this issue. Thank you for reporting it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.