Skip to content

Fixes stale cron list upon finishing a long-running job #9496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/wp-includes/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ function wp_unschedule_event( $timestamp, $hook, $args = array(), $wp_error = fa
return $pre;
}

$crons = _get_cron_array();
$crons = _get_cron_array( true );
$key = md5( serialize( $args ) );

unset( $crons[ $timestamp ][ $hook ][ $key ] );
Expand Down Expand Up @@ -1223,9 +1223,14 @@ function wp_get_ready_cron_jobs() {
* @since 6.1.0 Return type modified to consistently return an array.
* @access private
*
* @param bool $fresh whether a non-cached version is required
* @return array[] Array of cron events.
*/
function _get_cron_array() {
function _get_cron_array( $fresh = false ) {
if ( $fresh ) {
wp_cache_delete( 'alloptions', 'options' ); // there doesn't seem to be a more surgical way
}

$cron = get_option( 'cron' );
if ( ! is_array( $cron ) ) {
return array();
Expand Down
Loading