Skip to content

Commit 09f4ab1

Browse files
committed
Merge branch 'main' into copilot/add-network-flag-event-run
2 parents 01ac65c + 954e515 commit 09f4ab1

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

.github/workflows/code-quality.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
branches:
77
- main
88
- master
9+
schedule:
10+
- cron: '17 2 * * *' # Run every day on a seemly random time.
911

1012
jobs:
1113
code-quality:

features/cron-event.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,18 @@ Feature: Manage WP Cron events
197197
"""
198198
Success: Executed a total of 2 cron events across 3 sites.
199199
"""
200+
201+
Scenario: Confirm that cron event run in debug mode shows the start of events
202+
When I try `wp cron event run wp_version_check --debug=cron`
203+
Then STDOUT should contain:
204+
"""
205+
Executed the cron event 'wp_version_check'
206+
"""
207+
And STDOUT should contain:
208+
"""
209+
Executed a total of 1 cron event
210+
"""
211+
And STDERR should contain:
212+
"""
213+
Debug: Beginning execution of cron event 'wp_version_check'
214+
"""

src/Cron_Event_Command.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,19 @@ public function schedule( $args, $assoc_args ) {
186186
}
187187

188188
if ( ! empty( $recurrence ) ) {
189-
190189
$schedules = wp_get_schedules();
191190

192191
if ( ! isset( $schedules[ $recurrence ] ) ) {
193192
WP_CLI::error( sprintf( "'%s' is not a valid schedule name for recurrence.", $recurrence ) );
194193
}
195194

195+
// WordPress expects a list bug we knowingly pass an associative array.
196+
// @phpstan-ignore argument.type
196197
$event = wp_schedule_event( $timestamp, $recurrence, $hook, $assoc_args );
197-
198198
} else {
199-
199+
// Ditto.
200+
// @phpstan-ignore argument.type
200201
$event = wp_schedule_single_event( $timestamp, $hook, $assoc_args );
201-
202202
}
203203

204204
if ( false !== $event ) {
@@ -402,6 +402,7 @@ private static function run_events( array $events ) {
402402
$executed = 0;
403403

404404
foreach ( $events as $event ) {
405+
WP_CLI::debug( sprintf( "Beginning execution of cron event '%s'.", $event->hook ), 'cron' );
405406
$start = microtime( true );
406407
self::run_event( $event );
407408
$total = round( microtime( true ) - $start, 3 );

0 commit comments

Comments
 (0)