[wp-trac] [WordPress Trac] #44818: cron: preventing duplicate events fails when the first event is too far in the past

WordPress Trac noreply at wordpress.org
Sun Sep 30 23:53:22 UTC 2018


#44818: cron: preventing duplicate events fails when the first event is too far in
the past
-------------------------------------------------+-------------------------
 Reporter:  bodohugobarwich                      |       Owner:
                                                 |  peterwilsoncc
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:  5.0
Component:  Cron API                             |     Version:  2.7
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  refresh                                        |
-------------------------------------------------+-------------------------
Changes (by peterwilsoncc):

 * keywords:  has-patch has-unit-tests => has-patch has-unit-tests needs-
     refresh
 * milestone:  Awaiting Review => 5.0


Comment:

 Replying to [comment:11 bodohugobarwich]:

 Thanks for the patch and, particularly, for including unit tests.

 If the requested time stamp is less than ten minutes in the future, then
 `$mintimestamp` will need to be `0` as WP Cron spawns jobs for anything
 scheduled as `time()` or earlier.

 To avoid nesting the isset check, I'd prefer to reverse the logic of `(
 $event_timestamp  >= $mintimestamp && $event_timestamp <= $maxtimestamp )`
 and put a continue statement in there. This is a nit but nested logic can
 make reading the code a little more difficult.

 For a few reasons, I'd prefer to keep the logic in
 `wp_schedule_single_event()` rather than in a new function:

 * it's only used on one place
 * WordPress version 5.0 will add a few filters to make custom cron runners
 simpler (such as Automattic's Cron Control and Human Made's Cavalcade); a
 new function will require another hook.

 I've put this against the version 5.0 milestone as I think it's pretty
 much ready to go. I've also labelled it as needing a refresh, I can do
 this if you don't have time.

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


More information about the wp-trac mailing list