Ticket #35491: wp_next_scheduled.diff
| File wp_next_scheduled.diff, 2.4 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/cron.php
diff --git src/wp-includes/cron.php src/wp-includes/cron.php index 493e0ec..3028afe 100644
function wp_clear_scheduled_hook( $hook, $args = array() ) { 214 214 * Retrieve the next timestamp for a cron event. 215 215 * 216 216 * @since 2.1.0 217 * @since 4.5.0 The `$args` parameter can now be `false`. 217 218 * 218 * @param string $hook Action hook to execute when cron is run. 219 * @param array $args Optional. Arguments to pass to the hook's callback function. 219 * @param string $hook Action hook to execute when cron is run. 220 * @param array|false $args Optional. Arguments to pass to the hook's callback function. 221 * Pass false for any arguments. Default empty. 220 222 * @return false|int The UNIX timestamp of the next time the scheduled event will occur. 221 223 */ 222 224 function wp_next_scheduled( $hook, $args = array() ) { … … function wp_next_scheduled( $hook, $args = array() ) { 225 227 if ( empty($crons) ) 226 228 return false; 227 229 foreach ( $crons as $timestamp => $cron ) { 228 if ( isset( $cron[$hook][$key] ) )230 if ( false === $args && isset( $cron[ $hook ] ) || isset( $cron[$hook][$key] ) ) 229 231 return $timestamp; 230 232 } 231 233 return false; -
tests/phpunit/tests/cron.php
diff --git tests/phpunit/tests/cron.php tests/phpunit/tests/cron.php index b411a5b..892b92d 100644
class Tests_Cron extends WP_UnitTestCase { 85 85 86 86 } 87 87 88 /** 89 * @ticket 35491 90 */ 91 function test_wp_next_scheduled_no_args() { 92 $hook = rand_str(); 93 $ts1 = strtotime( '+30 minutes' ); 94 $ts2 = strtotime( '+2 hours' ); 95 96 $this->assertFalse( wp_next_scheduled( $hook, false ) ); 97 98 wp_schedule_event( $ts1, 'hourly', $hook, array( 'foo' ) ); 99 wp_schedule_event( $ts2, 'daily', $hook, 'bar' ); 100 wp_schedule_event( $ts2, 'twicedaily', $hook, array( 'baz' ) ); 101 102 $this->assertSame( $ts1, wp_next_scheduled( $hook, false ) ); 103 104 wp_unschedule_event( $ts1, $hook, array( 'foo' ) ); 105 $this->assertSame( $ts2, wp_next_scheduled( $hook, false ) ); 106 107 wp_unschedule_event( $ts2, $hook, 'bar' ); 108 $this->assertSame( $ts2, wp_next_scheduled( $hook, false ) ); 109 110 wp_unschedule_event( $ts2, $hook, array( 'baz' ) ); 111 $this->assertFalse( wp_next_scheduled( $hook, false ) ); 112 } 113 88 114 function test_unschedule_event() { 89 115 // schedule an event and make sure it's returned by wp_next_scheduled 90 116 $hook = rand_str();
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)