[wp-trac] [WordPress Trac] #49693: Drop duplicate recurring cron events

WordPress Trac noreply at wordpress.org
Sun Jul 5 22:13:34 UTC 2020


#49693: Drop duplicate recurring cron events
-------------------------------------------------+-------------------------
 Reporter:  aidvu                                |       Owner:  whyisjake
     Type:  enhancement                          |      Status:  accepted
 Priority:  normal                               |   Milestone:  5.6
Component:  Cron API                             |     Version:  5.4
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  testing needs-dev-note needs-refresh           |
-------------------------------------------------+-------------------------

Comment (by peterwilsoncc):

 > This is true. I went with the idea from this comment:
 https://core.trac.wordpress.org/ticket/49693#comment:12. Boils down to,
 make a safeguard so that situations that usually occur (adding events on
 every pageload because of a typo in the event name wouldn't break WP).
 Also, even if you did manage to add 500 duplicate daily events, the
 reschedule would drop them.
 >
 > I also wanted to keep the logic simple. In a 24 hour interval, max
 duplicate recurring events is 24.

 The issue I have with this approach is that it basically introduces a
 known bug to the logic check. The 10 minute window for single scheduled
 events had a bug for years and was causing problems.

 I'm still not convinced this is needed in core, but if it's going to be
 done, it needs to be done properly.

 FWIW, to avoid the [https://wordpress.org/support/topic/error-in-
 addcustomcronschedule-degrades-site-performance/ plugin issue linked
 above], I would rather create a wrapper function to schedule an event only
 if it's not scheduled.


 {{{
 function wp_maybe_schedule_event() {
   if ( wp_next_scheduled() ) {
     return false;
   }

   return wp_schedule_event();
 }
 }}}

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


More information about the wp-trac mailing list