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

WordPress Trac noreply at wordpress.org
Fri Mar 27 16:02:51 UTC 2020


#49693: Drop duplicate recurring cron events
----------------------------------------------------+---------------------
 Reporter:  aidvu                                   |       Owner:  (none)
     Type:  enhancement                             |      Status:  new
 Priority:  normal                                  |   Milestone:  5.5
Component:  Cron API                                |     Version:  trunk
 Severity:  normal                                  |  Resolution:
 Keywords:  has-patch has-unit-tests needs-testing  |     Focuses:
----------------------------------------------------+---------------------

Comment (by aidvu):

 Thank you for the feedback @azaozz and @peterwilsoncc! 🙇

 > Rather than adding new arguments I'd like to switch to an $args array.

 Is this the same thing I suggested here:
 https://core.trac.wordpress.org/ticket/49693#comment:1 ?

 > I'm not sure preventing multiple identically scheduled events is ideal.
 I can think of legitimate reasons for running the same hook & args
 combination twice.


 Isn't this the reason why we have custom intervals:
 https://developer.wordpress.org/plugins/cron/understanding-wp-cron-
 scheduling/

 It might be easier to schedule duplicates with different start times, but
 I think the right way for such schedules would be a custom interval.

 > The only thing left here is perhaps to try to figure out if any plugins
 will be negatively affected by this change. As far as I see there are a
 handful of plugin that call wp_reschedule_event()

 Hmm, `wp_reschedule_event()` is only affected in case of the
 `alternative.patch`. Since we're not going with that one, behavior stays
 unchanged (except what was proposed in the patch).

 > Rather than adding new arguments I'd like to switch to an $args array.

 Just to be sure, you want to pass the `rescheduling` param as part of the
 `$args` to the functions?

 e.g.

 - When calling `wp_reschedule_event()`, we set a special rescheduling
 param in `$args`. I'd go with `wp_cron_$hook_rescheduling`, to avoid
 collisions.
 - In `wp_schedule_event()` we look at this param, and unset it if set (so
 the $args match the original jobs args)
 - We use the variable to decide whether to skip the duplicate check or
 not.

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


More information about the wp-trac mailing list