Skip to content

Commit bb665fd

Browse files
committed
Merge branch 'main' into copilot/add-cron-event-actions-display
2 parents 54f2fbd + 954e515 commit bb665fd

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

.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
@@ -229,3 +229,18 @@ Feature: Manage WP Cron events
229229
"""
230230
None
231231
"""
232+
233+
Scenario: Confirm that cron event run in debug mode shows the start of events
234+
When I try `wp cron event run wp_version_check --debug=cron`
235+
Then STDOUT should contain:
236+
"""
237+
Executed the cron event 'wp_version_check'
238+
"""
239+
And STDOUT should contain:
240+
"""
241+
Executed a total of 1 cron event
242+
"""
243+
And STDERR should contain:
244+
"""
245+
Debug: Beginning execution of cron event 'wp_version_check'
246+
"""

src/Cron_Event_Command.php

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

197197
if ( ! empty( $recurrence ) ) {
198-
199198
$schedules = wp_get_schedules();
200199

201200
if ( ! isset( $schedules[ $recurrence ] ) ) {
202201
WP_CLI::error( sprintf( "'%s' is not a valid schedule name for recurrence.", $recurrence ) );
203202
}
204203

204+
// WordPress expects a list bug we knowingly pass an associative array.
205+
// @phpstan-ignore argument.type
205206
$event = wp_schedule_event( $timestamp, $recurrence, $hook, $assoc_args );
206-
207207
} else {
208-
208+
// Ditto.
209+
// @phpstan-ignore argument.type
209210
$event = wp_schedule_single_event( $timestamp, $hook, $assoc_args );
210-
211211
}
212212

213213
if ( false !== $event ) {
@@ -252,6 +252,7 @@ public function run( $args, $assoc_args ) {
252252

253253
$executed = 0;
254254
foreach ( $events as $event ) {
255+
WP_CLI::debug( sprintf( "Beginning execution of cron event '%s'.", $event->hook ), 'cron' );
255256
$start = microtime( true );
256257
$result = self::run_event( $event );
257258
$total = round( microtime( true ) - $start, 3 );

0 commit comments

Comments
 (0)