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

WordPress Trac noreply at wordpress.org
Sat Jul 4 09:31: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           |
-------------------------------------------------+-------------------------
Changes (by peterwilsoncc):

 * keywords:  has-patch has-unit-tests needs-testing needs-dev-note => has-
     patch has-unit-tests needs-testing needs-dev-note needs-refresh
 * milestone:  5.5 => 5.6


Comment:

 I'm going to bump this from 5.5 as I think it needs a few things before
 it's ready to add to Core, and I'd rather not rush it for next week given
 Cron's importance for auto-updates, scheduled posts, etc.

 A few notes on the proposed patch:

 * the current timing test is incomplete, a daily event can be added 500
 times if you start 500 days out and work back to tomorrow. If this is to
 be done, I'd rather do it properly by using the interval to determine a
 remainder, I recall some issues with single events due the the imprecise
 logic it had until recently
 * `min_timestamp` and `max_timestamp` will need the additional
 calculations for events scheduled around `time()`, see the other cron
 functions for these.
 * Create a filter for `$allowed_occurrences` and pass the event details
 * `$allowed_occurrences === true` (or another such value) to allow for
 unlimited occurrences if a plugin filters for it.
 * In the tests, rather than `$max_events = DAY_IN_SECONDS /
 HOUR_IN_SECONDS;`, etc, put in the expected values (24, etc) -- otherwise
 you're testing the code by running the code, which will always pass.
 * Additional tests will be needed to ensure the same hook with different
 arguments or intervals are not considered duplicates

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


More information about the wp-trac mailing list