|
28 | 28 | * @package wp-cli |
29 | 29 | */ |
30 | 30 | class Cron_Event_Command extends WP_CLI_Command { |
31 | | - |
| 31 | + /** |
| 32 | + * @var string[] |
| 33 | + */ |
32 | 34 | private $fields = array( |
33 | 35 | 'hook', |
34 | 36 | 'next_run_gmt', |
35 | 37 | 'next_run_relative', |
36 | 38 | 'recurrence', |
37 | 39 | ); |
38 | 40 |
|
| 41 | + /** |
| 42 | + * @var string |
| 43 | + */ |
39 | 44 | private static $time_format = 'Y-m-d H:i:s'; |
40 | 45 |
|
41 | 46 | /** |
@@ -154,13 +159,17 @@ public function list_( $args, $assoc_args ) { |
154 | 159 | * # Schedule new cron event and pass arguments |
155 | 160 | * $ wp cron event schedule cron_test '+1 hour' --0=first-argument --1=second-argument |
156 | 161 | * Success: Scheduled event with hook 'cron_test' for 2016-05-31 11:21:35 GMT. |
| 162 | + * |
| 163 | + * @param array{0: string, 1?: string, 2?: string} $args Positional arguments. |
| 164 | + * @param array<int, string> $assoc_args Associative arguments. |
157 | 165 | */ |
158 | 166 | public function schedule( $args, $assoc_args ) { |
159 | 167 | if ( count( $assoc_args ) && count( array_filter( array_keys( $assoc_args ), 'is_string' ) ) ) { |
160 | 168 | WP_CLI::warning( 'Numeric keys should be used for the hook arguments.' ); |
161 | 169 | } |
162 | 170 |
|
163 | | - $hook = $args[0]; |
| 171 | + $hook = $args[0]; |
| 172 | + |
164 | 173 | $next_run = Utils\get_flag_value( $args, 1, 'now' ); |
165 | 174 | $recurrence = Utils\get_flag_value( $args, 2, false ); |
166 | 175 |
|
@@ -263,10 +272,6 @@ public function unschedule( $args, $assoc_args ) { |
263 | 272 |
|
264 | 273 | list( $hook ) = $args; |
265 | 274 |
|
266 | | - if ( Utils\wp_version_compare( '4.9.0', '<' ) ) { |
267 | | - WP_CLI::error( 'Unscheduling events is only supported from WordPress 4.9.0 onwards.' ); |
268 | | - } |
269 | | - |
270 | 275 | $unscheduled = wp_unschedule_hook( $hook ); |
271 | 276 |
|
272 | 277 | if ( empty( $unscheduled ) ) { |
@@ -457,6 +462,10 @@ protected static function get_cron_events( $is_due_now = false ) { |
457 | 462 | protected static function get_selected_cron_events( $args, $assoc_args ) { |
458 | 463 | $due_now = Utils\get_flag_value( $assoc_args, 'due-now' ); |
459 | 464 | $all = Utils\get_flag_value( $assoc_args, 'all' ); |
| 465 | + |
| 466 | + /** |
| 467 | + * @var string $exclude |
| 468 | + */ |
460 | 469 | $exclude = Utils\get_flag_value( $assoc_args, 'exclude' ); |
461 | 470 |
|
462 | 471 | if ( empty( $args ) && ! $due_now && ! $all ) { |
@@ -549,11 +558,18 @@ private static function interval( $since ) { |
549 | 558 | array( 1, 'second' ), |
550 | 559 | ); |
551 | 560 |
|
| 561 | + $name = 'second'; |
| 562 | + $count = 0; |
| 563 | + $seconds = 1; |
| 564 | + |
552 | 565 | // we only want to output two chunks of time here, eg: |
553 | 566 | // x years, xx months |
554 | 567 | // x days, xx hours |
555 | 568 | // so there's only two bits of calculation below: |
556 | 569 |
|
| 570 | + $i = 0; |
| 571 | + $j = 0; |
| 572 | + |
557 | 573 | // step one: the first chunk |
558 | 574 | for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) { |
559 | 575 | $seconds = $chunks[ $i ][0]; |
|
0 commit comments