Make WordPress Core

Changeset 26782 for trunk


Ignore:
Timestamp:
12/07/2013 09:12:51 AM (13 years ago)
Author:
dd32
Message:

Cron: Fix a case where a cache inconsistency can cause wp_clear_scheduled_hook() to enter an infinite loop. This unravels the function from using other cron api functions to looping over the cron array directly. See #25773

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/cron.php

    r26365 r26782  
    169169        }
    170170
    171         while ( $timestamp = wp_next_scheduled( $hook, $args ) )
    172                 wp_unschedule_event( $timestamp, $hook, $args );
     171        // This logic duplicates wp_next_scheduled()
     172        // It's required due to a scenario where wp_unschedule_event() fails due to update_option() failing,
     173        // and, wp_next_scheduled() returns the same schedule in an infinite loop.
     174        $crons = _get_cron_array();
     175        if ( empty( $crons ) )
     176                return;
     177
     178        $key = md5( serialize( $args ) );
     179        foreach ( $crons as $timestamp => $cron ) {
     180                if ( isset( $cron[ $hook ][ $key ] ) ) {
     181                        wp_unschedule_event( $timestamp, $hook, $args );
     182                }
     183        }
    173184}
    174185
Note: See TracChangeset for help on using the changeset viewer.