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
This commit is contained in:
Peter Wilson 2022-09-09 01:53:11 +00:00
parent 5f55192c9a
commit b8f713ab09
2 changed files with 4 additions and 7 deletions

View File

@ -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;
}

View File

@ -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.