Make WordPress Core


Ignore:
Timestamp:
07/29/2022 03:32:58 AM (2 years ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/wpMediaListTable.php

    r51639 r53791  
    2525     * @ticket 53949
    2626     * @covers WP_Media_List_Table::prepare_items
     27     * @group cron
    2728     */
    2829    public function test_prepare_items_without_cron_option_does_not_throw_warning() {
     
    4344
    4445        // Verify that the cause of the error is in place.
    45         $this->assertFalse( _get_cron_array(), '_get_cron_array() does not return false' );
     46        $this->assertIsArray( _get_cron_array(), '_get_cron_array() does not return an array.' );
     47        $this->assertEmpty( _get_cron_array(), '_get_cron_array() does not return an empty array.' );
    4648
    4749        // If this test does not error out due to the PHP warning, we're good.
Note: See TracChangeset for help on using the changeset viewer.