Make WordPress Core

Changeset 52663


Ignore:
Timestamp:
02/02/2022 11:24:40 PM (2 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, audrasjb.
Merges [52656] and [52662] to the 5.9 branch.
Fixes #54906.
See #53940.

Location:
branches/5.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.9

  • branches/5.9/src/wp-admin/includes/upgrade.php

    r52462 r52663  
    22702270    if ( $wp_current_db_version < 51917 ) {
    22712271        $crons = _get_cron_array();
    2272         // Remove errant `false` values, see #53950.
    2273         $crons = array_filter( $crons );
    2274         _set_cron_array( $crons );
     2272
     2273        if ( $crons && is_array( $crons ) ) {
     2274            // Remove errant `false` values, see #53950, #54906.
     2275            $crons = array_filter( $crons );
     2276            _set_cron_array( $crons );
     2277        }
    22752278    }
    22762279}
Note: See TracChangeset for help on using the changeset viewer.