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.

Built from https://develop.svn.wordpress.org/trunk@52656


git-svn-id: http://core.svn.wordpress.org/trunk@52245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2022-02-01 00:14:06 +00:00
parent 8de9cdf559
commit 1ee362004f
2 changed files with 7 additions and 4 deletions

View File

@ -2273,9 +2273,12 @@ function upgrade_590() {
if ( $wp_current_db_version < 51917 ) {
$crons = _get_cron_array();
// Remove errant `false` values, see #53950.
$crons = array_filter( $crons );
_set_cron_array( $crons );
if ( $crons && is_array( $crons ) ) {
// Remove errant `false` values, see #53950.
$crons = array_filter( $crons );
_set_cron_array( $crons );
}
}
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-alpha-52655';
$wp_version = '6.0-alpha-52656';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.