[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
Thu Aug 23 13:54:01 UTC 2018


#44818: cron: preventing duplicate events fails when the first event is too far in
the past
-----------------------------+------------------------------
 Reporter:  bodohugobarwich  |       Owner:  (none)
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Cron API         |     Version:  4.9.8
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:
-----------------------------+------------------------------

Comment (by bodohugobarwich):

 Yes, exactly.

 If you have {{{my_cron_hook}}} scheduled for {{{1/1/2016 12:00:00}}} and
 {{{1/1/2028 12:00:00}}}\\

 the function:\\
 {{{
 wp_next_scheduled($hook, $args);
 }}}

 returns allways the timestamp of the first event which would be
 {{{1451649600}}}

 Thus the Function continues running and accepts {{{1/1/2028 12:00:01}}} as
 next valid timestamp


 {{{
 $ date --date="1/1/2016 12:00:00" +"%s"
 1451649600
 $ date --date="1/1/2028 12:00:00" +"%s"
 1830340800
 $ date --date="1/1/2028 12:00:01" +"%s"
 1830340801
 $ php -r "echo abs( 1451649600 - time()) . \" < \". (10*60) . \" => \" .
 (int)(abs( 1451649600 - time()) < (10*60)) . \"\\n\";"
 83382382 < 600 => 0
 $ php -r "echo abs( 1451649601 - time()) . \" < \". (10*60) . \" => \" .
 (int)(abs( 1451649601 - time()) < (10*60)) . \"\\n\";"
 83382543 < 600 => 0
 }}}

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


More information about the wp-trac mailing list