From b8f713ab09cf165e4af8ab49eed5854178829f25 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 9 Sep 2022 01:53:11 +0000 Subject: [PATCH] Cron API: Remove unnecessary optimization getting ready events. Remove the check for future events prior iterating the array of crons in `wp_get_ready_cron_jobs()`. If there are no ready events, the `foreach` loop will break on the first iteration so the optimization is not required. As WordPress Core adds a number of events by default, accounting for an empty array is not required in most instances. Props lev0, jrf, SergeyBiryukov. Fixes #56092. Built from https://develop.svn.wordpress.org/trunk@54110 git-svn-id: http://core.svn.wordpress.org/trunk@53669 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/cron.php | 9 +++------ wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/wp-includes/cron.php b/wp-includes/cron.php index f04088061a..9e83942f70 100644 --- a/wp-includes/cron.php +++ b/wp-includes/cron.php @@ -1122,23 +1122,20 @@ function wp_get_ready_cron_jobs() { * to continue using results from _get_cron_array(). */ $pre = apply_filters( 'pre_get_ready_cron_jobs', null ); + if ( null !== $pre ) { return $pre; } $crons = _get_cron_array(); - $gmt_time = microtime( true ); - $keys = array_keys( $crons ); - if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) { - return array(); - } - $results = array(); + foreach ( $crons as $timestamp => $cronhooks ) { if ( $timestamp > $gmt_time ) { break; } + $results[ $timestamp ] = $cronhooks; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 67dfb0965a..0f0f139502 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-54109'; +$wp_version = '6.1-alpha-54110'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.