[wp-trac] [WordPress Trac] #53950: `wp_schedule_single_event()` may add incorrectly populate the cron array.
WordPress Trac
noreply at wordpress.org
Mon Oct 18 12:51:15 UTC 2021
#53950: `wp_schedule_single_event()` may add incorrectly populate the cron array.
--------------------------------------+-----------------------------
Reporter: peterwilsoncc | Owner: hellofromTonya
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 5.9
Component: Cron API | Version: 5.2
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+-----------------------------
Changes (by hellofromTonya):
* owner: (none) => hellofromTonya
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"51916" 51916]:
{{{
#!CommitTicketReference repository="" revision="51916"
Cron: Fix malformed cron array in `wp_schedule_single_event()` when
`_get_cron_array()` returns `false`.
In `wp_schedule_single_event()`, the cron info array is retrieved via a
call to `_get_cron_array()` and straight away cast to an array. But as the
documentation for that function (correctly) states, the return type of
that function is `array|false`, where `false` is returned for a site where
no cron jobs have been scheduled (yet).
In the case that `_get_cron_array()` would return `false`, this would now
unintentionally create an array with a single entry with key `0` and as
the value `false`.
This is a bug. Fixed now by adding validation to the output of
`_get_cron_array()` and initializing `$crons` to an empty array if `false`
was returned.
Tests added first to prove the bug (a) was introduced in #44818 [44917]
and (b) is now fixed.
Follow-up to [44917].
Props jrf, peterwilsoncc.
Fixes #53950.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53950#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list