From b03c6c171ca8b5f61fd22524432a60315540de88 Mon Sep 17 00:00:00 2001 From: Slavic Dragovtev Date: Sat, 16 Aug 2025 02:18:30 +0300 Subject: [PATCH 1/2] Fixes stale cron list upon finishing a long-running job --- src/wp-includes/cron.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/cron.php b/src/wp-includes/cron.php index 39b61ae35603e..f945852981382 100644 --- a/src/wp-includes/cron.php +++ b/src/wp-includes/cron.php @@ -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 ] ); @@ -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(); From d3b6a08ccd852256956c09307f434198b5ef4c73 Mon Sep 17 00:00:00 2001 From: Slavic Dragovtev Date: Sat, 16 Aug 2025 02:32:44 +0300 Subject: [PATCH 2/2] coding style fix --- src/wp-includes/cron.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/cron.php b/src/wp-includes/cron.php index f945852981382..9b7ffbf709694 100644 --- a/src/wp-includes/cron.php +++ b/src/wp-includes/cron.php @@ -1228,7 +1228,7 @@ function wp_get_ready_cron_jobs() { */ function _get_cron_array( $fresh = false ) { if ( $fresh ) { - wp_cache_delete( 'alloptions', 'options' ); // there doesn't seem to be a more surgical way + wp_cache_delete( 'alloptions', 'options' ); // there doesn't seem to be a more surgical way } $cron = get_option( 'cron' );