[wp-trac] [WordPress Trac] #28213: wp_schedule_single_event() prevents scheduling a future event when it should not

WordPress Trac noreply at wordpress.org
Mon May 12 06:20:28 UTC 2014


#28213: wp_schedule_single_event() prevents scheduling a future event when it
should not
--------------------------+-----------------------------
 Reporter:  tellyworth    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Cron API      |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 [9181] added some defensive code to wp_schedule_single_event() suggested
 in #6966, to stop scheduling duplicate events in the event of a flood.

 That patch did solve the intended problem, but also introduced some
 unintended behaviour. If an event is currently executing, or is past due
 but hasn't completed for some reason, it will refuse to schedule a similar
 event ''at any future time'' - even if you attempt to schedule something
 weeks ahead.

 This turned up when testing the Akismet plugin: in the event that servers
 are unreachable, the cron_recheck() hook attempts to re-schedule itself
 for 6 hours in the future. But wp_schedule_single_event() rejects it
 because there is already a similar event scheduled a few seconds in the
 past (itself).

 That wasn't the intent of the original fix, and I think it should be
 considered a bug. I'd suggest that wp_schedule_single_event() should only
 reject an event as a duplicate if there is already a similar event
 scheduled within 10 minutes of the given timestamp.

 While testing this I discovered there's a bug in the associated unit test,
 Tests_Cron::test_not_duplicate_event(). It schedules two future events and
 checks that they are both there. wp_next_scheduled() returns the wrong
 event (it returns the later event, not the next), but the test as written
 incorrectly accepts this as expected behaviour.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28213>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list