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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52656 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson 2022-02-01 00:12:33 +00:00
parent 2bbe1b7f40
commit 9e03599af8

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