From 6b2eccb0e3bf8ec781e6baa02e1ab40de17a7aff Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Mon, 30 Aug 2021 15:20:56 +0000 Subject: [PATCH] Code Modernization: Add input validation to `_set_cron_array()`. The private `_set_cron_array()` function expects a cron array as the first parameter, but will often be passed the - potentially updated - output of a call to `_get_cron_array()`. When the `_get_cron_array()` function returns `false`, a "Deprecated: Automatic conversion of false to array is deprecated" warning will be thrown on PHP 8.1. The input validation resolves the deprecation warning by setting the cron value to an empty array when not given an `array` data type. Adds a full set of `_set_cron_array()` tests. Follow-up to [4189], [50152]. Props jrf, hellofromTonya, peterwilsoncc. See #53635. Built from https://develop.svn.wordpress.org/trunk@51695 git-svn-id: http://core.svn.wordpress.org/trunk@51301 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/cron.php | 4 ++++ wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/cron.php b/wp-includes/cron.php index 18fe14196e..f4810e55a3 100644 --- a/wp-includes/cron.php +++ b/wp-includes/cron.php @@ -1191,6 +1191,10 @@ function _get_cron_array() { * @return bool|WP_Error True if cron array updated. False or WP_Error on failure. */ function _set_cron_array( $cron, $wp_error = false ) { + if ( ! is_array( $cron ) ) { + $cron = array(); + } + $cron['version'] = 2; $result = update_option( 'cron', $cron ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 6caf5af09a..b8e52d1017 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51693'; +$wp_version = '5.9-alpha-51695'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.