WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#6966 closed defect (bug) (fixed)

cron: prevent duplicate events

Reported by: tellyworth Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch, has-test
Focuses: Cc:

Description

This is an unusual case but worth defending against:

If a user submits many posts in a short period of time (perhaps with XML-RPC), the cron array can fill up with a backlog of do_pings events. Since do_pings operates on all posts, there's no reason to have more than one of these events scheduled.

The enclosed patch changes wp_schedule_single_event() to ignore new events if there is already an identical event scheduled within 10 minutes of the new one. (It also handles the case where there's a backlog of events with timestamps in the past). The hook and args must be identical for it to be skipped. 10 minutes is arbitrary but seems reasonable; it could be an external define if there's a need to change it.

Attachments (1)

cron-ignore-duplicate-events-r7916.3.patch (621 bytes) - added by tellyworth 11 years ago.

Download all attachments as: .zip

Change History (3)

#1 @tellyworth
11 years ago

  • Keywords has-patch has-test added

Unit tests are in http://svn.automattic.com/wordpress-tests/wp-testcase/test_cron.php, test_duplicate_event() and test_not_duplicate_event(). All tests pass with the patch applied.

#2 @ryan
11 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [9181]) don't schedule a duplicate if there's already an identical event due in the next 10 minutes. Props tellyworth. fixes #6966

Note: See TracTickets for help on using tickets.