Make WordPress Core

Changeset 27886


Ignore:
Timestamp:
04/01/2014 03:39:35 AM (10 years ago)
Author:
nacin
Message:

Cron: Fix a case where a cache inconsistency can cause wp_clear_scheduled_hook() to enter an infinite loop.

Merges [26782] from 3.8 to the 3.7 branch.

props dd32.
fixes #25773.

Location:
branches/3.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/src/wp-includes/cron.php

    r23591 r27886  
    161161    }
    162162
    163     while ( $timestamp = wp_next_scheduled( $hook, $args ) )
    164         wp_unschedule_event( $timestamp, $hook, $args );
     163    // This logic duplicates wp_next_scheduled()
     164    // It's required due to a scenario where wp_unschedule_event() fails due to update_option() failing,
     165    // and, wp_next_scheduled() returns the same schedule in an infinite loop.
     166    $crons = _get_cron_array();
     167    if ( empty( $crons ) )
     168        return;
     169
     170    $key = md5( serialize( $args ) );
     171    foreach ( $crons as $timestamp => $cron ) {
     172        if ( isset( $cron[ $hook ][ $key ] ) ) {
     173            wp_unschedule_event( $timestamp, $hook, $args );
     174        }
     175    }
    165176}
    166177
Note: See TracChangeset for help on using the changeset viewer.