Make WordPress Core


Ignore:
Timestamp:
09/09/2022 01:51:52 AM (2 years ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/cron.php

    r53878 r54110  
    11231123     */
    11241124    $pre = apply_filters( 'pre_get_ready_cron_jobs', null );
     1125
    11251126    if ( null !== $pre ) {
    11261127        return $pre;
     
    11281129
    11291130    $crons = _get_cron_array();
    1130 
    11311131    $gmt_time = microtime( true );
    1132     $keys     = array_keys( $crons );
    1133     if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) {
    1134         return array();
    1135     }
    1136 
    11371132    $results = array();
     1133
    11381134    foreach ( $crons as $timestamp => $cronhooks ) {
    11391135        if ( $timestamp > $gmt_time ) {
    11401136            break;
    11411137        }
     1138
    11421139        $results[ $timestamp ] = $cronhooks;
    11431140    }
Note: See TracChangeset for help on using the changeset viewer.