Make WordPress Core


Ignore:
Timestamp:
02/01/2022 12:12:33 AM (3 years ago)
Author:
peterwilsoncc
Message:

Upgrade: Prevent warnings upgrading cron array.

An unvisited site may have an undefined cron array, resulting in _get_cron_array() returning the value false. Previously this would trigger warning in upgrade_590() as the function assumed _get_cron_array() would alway return an array.

No database version change is required as the upgrade routine was successful on sites with a cron array during 5.9.0. On sites without a cron array, the error has already been thrown if they are running db version 51917. This fix is only required for new sites or those upgrading that have skipped 5.9.0.

Follow up to [51917].

Props chrisvanpatten, kapilpaul, SergeyBiryukov.
Fixes #54906.
See #53940.

File:
1 edited

Legend:

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

    r52456 r52656  
    22742274    if ( $wp_current_db_version < 51917 ) {
    22752275        $crons = _get_cron_array();
    2276         // Remove errant `false` values, see #53950.
    2277         $crons = array_filter( $crons );
    2278         _set_cron_array( $crons );
     2276
     2277        if ( $crons && is_array( $crons ) ) {
     2278            // Remove errant `false` values, see #53950.
     2279            $crons = array_filter( $crons );
     2280            _set_cron_array( $crons );
     2281        }
    22792282    }
    22802283}
Note: See TracChangeset for help on using the changeset viewer.