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. Built from https://develop.svn.wordpress.org/branches/3.7@27886 git-svn-id: http://core.svn.wordpress.org/branches/3.7@27717 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8d9c69ffc4
commit
7a01e960b5
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue