From ea679e358eb5bbcdfd610ba0fd48548b01ee9d0f Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 17 Oct 2014 19:17:18 +0000 Subject: [PATCH] `wp_schedule_single_event()` should not prevent scheduling a future duplicate event. It should only reject an event as a duplicate if there is already a similar event scheduled within 10 minutes of the given timestamp. Adds unit tests, fixes existing cron test. Props tellyworth. See [9181], #6966. Fixes #28213. Built from https://develop.svn.wordpress.org/trunk@29939 git-svn-id: http://core.svn.wordpress.org/trunk@29690 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/cron.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-includes/cron.php b/wp-includes/cron.php index 244699c8ed..c4ce866cf6 100644 --- a/wp-includes/cron.php +++ b/wp-includes/cron.php @@ -20,10 +20,11 @@ * @param array $args Optional. Arguments to pass to the hook's callback function. */ function wp_schedule_single_event( $timestamp, $hook, $args = array()) { - // don't schedule a duplicate if there's already an identical event due in the next 10 minutes + // don't schedule a duplicate if there's already an identical event due within 10 minutes of it $next = wp_next_scheduled($hook, $args); - if ( $next && $next <= $timestamp + 10 * MINUTE_IN_SECONDS ) + if ( $next && abs( $next - $timestamp ) <= 10 * MINUTE_IN_SECONDS ) { return; + } $crons = _get_cron_array(); $event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => false, 'args' => $args );