]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/cron.php
WordPress 3.7.2
[autoinstalls/wordpress.git] / wp-includes / cron.php
index 6668dc546e292ce77f9d859762d1798451340b48..1c68e146cf24902030c6537cf9d59b0a0064b299 100644 (file)
@@ -160,8 +160,19 @@ function wp_clear_scheduled_hook( $hook, $args = array() ) {
                $args = array_slice( func_get_args(), 1 );
        }
 
-       while ( $timestamp = wp_next_scheduled( $hook, $args ) )
-               wp_unschedule_event( $timestamp, $hook, $args );
+       // This logic duplicates wp_next_scheduled()
+       // It's required due to a scenario where wp_unschedule_event() fails due to update_option() failing,
+       // and, wp_next_scheduled() returns the same schedule in an infinite loop.
+       $crons = _get_cron_array();
+       if ( empty( $crons ) )
+               return;
+
+       $key = md5( serialize( $args ) );
+       foreach ( $crons as $timestamp => $cron ) {
+               if ( isset( $cron[ $hook ][ $key ] ) ) {
+                       wp_unschedule_event( $timestamp, $hook, $args );
+               }
+       }
 }
 
 /**