[wp-trac] [WordPress Trac] #49693: Drop duplicate recurring cron events
WordPress Trac
noreply at wordpress.org
Tue Mar 24 19:03:36 UTC 2020
#49693: Drop duplicate recurring cron events
-------------------------+--------------------------------------
Reporter: aidvu | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Cron API | Version: trunk
Severity: normal | Keywords: has-patch has-unit-tests
Focuses: |
-------------------------+--------------------------------------
It's easy to break a site by mistakenly scheduling millions of events
because of a typo or a bad check.
Here's one example: https://wordpress.org/support/topic/error-in-
addcustomcronschedule-degrades-site-performance/
In the past, I've also seen plugins use `get_option` and all kinds of
different checks, instead of `wp_next_scheduled`.
Fixing the site afterwards can be a bit of a PITA, specially for high
traffic ones. DB replication is often an issue when the `cron` option
grows in size due to the bug.
It's probably a good idea to prevent scheduling recurring events that have
the same hook, schedule and args.
Additional thoughts:
- This might make the `wp_next_scheduled` check obsolete when queuing an
event?
- Changing the arguments of `wp_schedule_event` isn't something I wanted
to do, but considering the current code for reschedule/unschedule in `wp-
cron.php`, it seemed the best route (case of missing schedule, and trying
to get interval from the event that we're rescheduling).
- We're currently doing this with a `schedule_event` filter. Another route
could be to add it to `default-filters`, but I think it should be in the
Cron API itself.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49693>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list