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

WordPress Trac noreply at wordpress.org
Fri Aug 28 03:00:15 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):

 Replying to [comment:23 aidvu]:
 > > 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.
 >
 > Is
 [https://github.com/WordPress/WordPress/commit/fff2440ba5b05e3846a76ea5dc3a1dc552670f9b
 this commit] what you're referring to?

 Yes, that's the commit I am referring to.

 > > I'm still not convinced this is needed in core, but if it's going to
 be done, it needs to be done properly.
 >
 > It's been a while, and at this point I'm not sure what the `done
 properly` would be in this case. Maybe what you suggested
 [https://core.trac.wordpress.org/ticket/49693#comment:7 here]?

 By done properly, I mean not allowing for edge case where the same event
 can be run more than the expected number of times in a period. IE, the
 same recurring event on a 24 hour schedule to be set up more than the
 allowed number of times in the period. That means accounting for past
 scheduled times and including all events in the count (ie, never `break`
 out of the loop counting events).

 > > FWIW, to avoid the plugin issue linked above, I would rather create a
 wrapper function to schedule an event only if it's not scheduled.
 >
 > Not against it. Would need a docs update and is probably good enough to
 avoid most problems although adoption will take time.

 That's what I am thinking, the docs are inline so can be updated as part
 of the code changes. A `Use wp_maybe_schedule** to only ensure events are
 not re-registered` type of comment should do.

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


More information about the wp-trac mailing list