Make WordPress Core


Ignore:
Timestamp:
07/29/2022 03:32:58 AM (3 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/cron.php

    r53573 r53791  
    131131
    132132        // Verify that the cause of the error is in place.
    133         $this->assertFalse( _get_cron_array(), '_get_cron_array() does not return false' );
     133        $this->assertIsArray( _get_cron_array(), '_get_cron_array() does not return an array.' );
     134        $this->assertEmpty( _get_cron_array(), '_get_cron_array() does not return an empty array.' );
    134135
    135136        $hook      = __FUNCTION__;
     
    152153
    153154        // Verify that the cause of the error is in place.
    154         $this->assertFalse( _get_cron_array(), '_get_cron_array() does not return false' );
     155        $this->assertIsArray( _get_cron_array(), '_get_cron_array() does not return an array.' );
     156        $this->assertEmpty( _get_cron_array(), '_get_cron_array() does not return an empty array.' );
    155157
    156158        $hook      = __FUNCTION__;
Note: See TracChangeset for help on using the changeset viewer.