[wp-trac] [WordPress Trac] #57271: Cron unschedule / reschedule event errors

WordPress Trac noreply at wordpress.org
Tue Dec 20 16:54:57 UTC 2022


#57271: Cron unschedule / reschedule event errors
----------------------------------------+------------------------------
 Reporter:  domainsupport               |       Owner:  audrasjb
     Type:  defect (bug)                |      Status:  assigned
 Priority:  normal                      |   Milestone:  Awaiting Review
Component:  Cron API                    |     Version:  6.0
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:
----------------------------------------+------------------------------

Comment (by courageous999):

 We're a live but not a high traffic site that has also started seeing this
 exact error since upgrading WordPress to v6.1.1. The errors started to
 appear sometime in November but I've been patiently ignoring them (since
 at the time I did not find any mention of it by anyone online).

 I had the following custom CRON event set in my child theme's
 `functions.php` file:

 {{{
 wp_schedule_event(strtotime('10:00:00'), 'daily',
 'ft_remove_stripe_cron');
 }}}
 This was throwing the following error in my `error_log` about 50 times a
 minute:

 {{{
 [20-Dec-2022 15:59:02 UTC] Cron reschedule event error for hook:
 ft_remove_stripe_cron, Error code: could_not_set, Error message: The cron
 event list could not be saved., Data:
 {"schedule":"daily","args":[],"interval":86400}
 }}}
 After going through this ticket, I was finally able to find out that what
 I needed was the following:

 {{{
 if ( !wp_next_scheduled('ft_remove_stripe_cron') )
     wp_schedule_event(strtotime('10:00:00'), 'daily',
 'ft_remove_stripe_cron');
 }}}
 Suffice to say that I have now had over 20 minutes of peace and quiet in
 my `error_log` since adding this!

 Now my understanding is that my implementation was always wrong and was
 always failing to schedule an already set CRON event (but silently
 before). However, I find it intriguing (and perhaps of value to your
 investigation) that I was receiving that error 50 times a minute. I
 guarantee you that our site was not receiving 50 visits a minute! I highly
 doubt it even had 1 link clicked a minute.

 Lastly, I should also mention that I've occasionally (amidst the barrage
 of repeated CRON event errors) seen other CRON events (not sure if set by
 a plugin or WordPress itself) also failing with this exact error.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57271#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list