I recently had an issue with a plugin that runs a wordpress cron. Up until recently it appeared to work fine. When I investigated further the cron was no longer in the list of scheduled cron jobs. My investigation took me to the function wp_schedule_event in cron.php, I found that this function was not getting past the code
if ( !isset( $schedules[$recurrence] ) ) return false;
now the value of $recurrence was ‘daily’ which is one of the standard values. I also discover in my debug that the function wp_schedule_update_checks() in update.php was being repeatedly called and each of the calls to wp_schedule_event() was running into the same issue I was having with my plugin.
Drilling further I went to the function wp_get_schedules() in cron.php
In that function it sets up the variable $schedules with the default recurrences then has the following line
return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
The returned merged array is empty for some reason hence if statement above fails. If I change the above line to
it works and even wp_schedule_update_checks() is successful. Though it means any custom schedules will not work.
If someone can explain what is happening or if this is a bug I would be grateful.
- The topic ‘wp_get_schedules not returning an array of schedules’ is closed to new replies.