Index: src/wp-cron.php =================================================================== --- src/wp-cron.php (revision 53556) +++ src/wp-cron.php (working copy) @@ -115,17 +115,61 @@ } foreach ( $cronhooks as $hook => $keys ) { - foreach ( $keys as $k => $v ) { - $schedule = $v['schedule']; if ( $schedule ) { - wp_reschedule_event( $timestamp, $schedule, $hook, $v['args'] ); + $result = wp_reschedule_event( $timestamp, $schedule, $hook, $v['args'], true ); + + if ( is_wp_error( $result ) ) { + error_log( + sprintf( + __( 'Cron reschedule event error for hook: %s, Error code: %s, Error message: %s, Data: %s' ), + $hook, + $result->get_error_code(), + $result->get_error_message(), + wp_json_encode( $v ) + ) + ); + + /** + * Fires when an error happens rescheduling a cron event. + * + * @since 6.1.0 + * + * @param WP_Error $result The WP_Error object or false. + * @param string $hook Action hook to execute when the event is run. + * @param array $v Event data. + */ + do_action( 'cron_reschedule_event_error', $result, $hook, $v ); + } } - wp_unschedule_event( $timestamp, $hook, $v['args'] ); + $result = wp_unschedule_event( $timestamp, $hook, $v['args'], true ); + if ( is_wp_error( $result ) ) { + error_log( + sprintf( + __( 'Cron unschedule event error for hook: %s, Error code: %s, Error message: %s, Data: %s' ), + $hook, + $result->get_error_code(), + $result->get_error_message(), + wp_json_encode( $v ) + ) + ); + + /** + * Fires when an error happens unscheduling a cron event. + * + * @since 6.1.0 + * + * @param WP_Error $result The WP_Error object or false. + * @param string $hook Action hook to execute when the event is run. + * @param array $v Event data. + */ + do_action( 'cron_unschedule_event_error', $result, $hook, $v ); + } + /** * Fires scheduled events. *