Skip to content

Commit c832e58

Browse files
Copilotswissspidy
andcommitted
Address code review: clean up network flag and log errors for sites without events
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 3d2b736 commit c832e58

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Cron_Event_Command.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,17 @@ public function run( $args, $assoc_args ) {
262262
WP_CLI::error( 'No sites found in the network.' );
263263
}
264264

265+
// Remove network flag before passing to get_selected_cron_events.
266+
$network_assoc_args = $assoc_args;
267+
unset( $network_assoc_args['network'] );
268+
265269
$total_executed = 0;
266270
$site_count = count( $sites );
267271

268272
foreach ( $sites as $site_id ) {
269273
switch_to_blog( $site_id );
270274

271-
$events = self::get_selected_cron_events( $args, $assoc_args );
275+
$events = self::get_selected_cron_events( $args, $network_assoc_args );
272276

273277
if ( ! is_wp_error( $events ) ) {
274278
foreach ( $events as $event ) {
@@ -281,6 +285,8 @@ public function run( $args, $assoc_args ) {
281285
WP_CLI::debug( sprintf( 'Arguments: %s', wp_json_encode( $event->args ) ), 'cron' );
282286
}
283287
}
288+
} else {
289+
WP_CLI::debug( sprintf( 'No events found for site %d: %s', $site_id, $events->get_error_message() ), 'cron' );
284290
}
285291

286292
restore_current_blog();

0 commit comments

Comments
 (0)