Cron API: Modify `_get_cron_array()` to always return an array.
Change the return type of `_get_cron_array()` to an empty array if the `cron` option is either missing or of an unexpected type. This change ensures the return value for no registered events is consistently an empty array. Previously the return value could be either an empty array or `false`. Props thakkarhardik, jrf, costdev. Fixes #53940. Built from https://develop.svn.wordpress.org/trunk@53791 git-svn-id: http://core.svn.wordpress.org/trunk@53350 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9646cd2a77
commit
839d20f9c5
|
@ -119,9 +119,6 @@ function wp_schedule_single_event( $timestamp, $hook, $args = array(), $wp_error
|
|||
* are considered duplicates.
|
||||
*/
|
||||
$crons = _get_cron_array();
|
||||
if ( ! is_array( $crons ) ) {
|
||||
$crons = array();
|
||||
}
|
||||
|
||||
$key = md5( serialize( $event->args ) );
|
||||
$duplicate = false;
|
||||
|
@ -306,9 +303,6 @@ function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array(), $wp
|
|||
$key = md5( serialize( $event->args ) );
|
||||
|
||||
$crons = _get_cron_array();
|
||||
if ( ! is_array( $crons ) ) {
|
||||
$crons = array();
|
||||
}
|
||||
|
||||
$crons[ $event->timestamp ][ $event->hook ][ $key ] = array(
|
||||
'schedule' => $event->schedule,
|
||||
|
@ -1133,9 +1127,6 @@ function wp_get_ready_cron_jobs() {
|
|||
}
|
||||
|
||||
$crons = _get_cron_array();
|
||||
if ( ! is_array( $crons ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$gmt_time = microtime( true );
|
||||
$keys = array_keys( $crons );
|
||||
|
@ -1162,14 +1153,15 @@ function wp_get_ready_cron_jobs() {
|
|||
* Retrieve cron info array option.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @since 6.1.0 Return type modified to consistenty return an array.
|
||||
* @access private
|
||||
*
|
||||
* @return array[]|false Array of cron info arrays on success, false on failure.
|
||||
* @return array[] Array of cron events.
|
||||
*/
|
||||
function _get_cron_array() {
|
||||
$cron = get_option( 'cron' );
|
||||
if ( ! is_array( $cron ) ) {
|
||||
return false;
|
||||
return array();
|
||||
}
|
||||
|
||||
if ( ! isset( $cron['version'] ) ) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.1-alpha-53790';
|
||||
$wp_version = '6.1-alpha-53791';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue