Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#56048 closed enhancement (fixed)

Add error logging and hooks to wp-cron.php

Reported by: enchiridion's profile Enchiridion Owned by: audrasjb's profile audrasjb
Milestone: 6.1 Priority: normal
Severity: normal Version:
Component: Cron API Keywords: has-patch commit add-to-field-guide
Focuses: Cc:

Description

Rarely and randomly some of my custom cron events have disappeared. From searching around, I'm not the only one with this issue, and no one else was able to figure out why. I also was unable to debug the issue since wp-cron.php doesn't log any errors nor have any hooks to try handling them. This patch adds those in.

Attachments (2)

56048.diff (2.0 KB) - added by Enchiridion 2 years ago.
56048.2.diff (2.1 KB) - added by costdev 2 years ago.
Patch updated to add translator comments, remove "or false" from docblocks, and revert two line removals.

Download all attachments as: .zip

Change History (8)

@Enchiridion
2 years ago

#1 @johnbillion
2 years ago

  • Milestone changed from Awaiting Review to 6.1
  • Type changed from defect (bug) to enhancement
  • Version trunk deleted

Thanks for the ticket and the patch @Enchiridion.

Both the actions and the error logging make sense here and are a useful addition. I did think it would be beneficial to hook the calls to error_log() in via the actions, but it's additional overhead to introduce two new functions for this very narrow use case, so I think the direct calls to error_log() can suffice.

#2 @johnbillion
2 years ago

  • Owner set to johnbillion
  • Status changed from new to reviewing

@costdev
2 years ago

Patch updated to add translator comments, remove "or false" from docblocks, and revert two line removals.

#3 @audrasjb
2 years ago

  • Keywords commit added

The patch works fine on my side and looks good to go.

As today is beta 1 release date, I'll self assign this enhancement so it can be committed in time for 6.1 beta 1. @johnbillion feel free to ping me if you're actively working on this right now so I can reassign it to you :)

#4 @audrasjb
2 years ago

  • Owner changed from johnbillion to audrasjb
  • Status changed from reviewing to accepted

#5 @audrasjb
2 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 54258:

Cron API: Add error logging and hooks to wp-cron.php.

This changeset adds error logging on wp_reschedule_event() and wp_unschedule_event in wp-cron.php. This allows proper error logging when random errors appear. It also introduces cron_reschedule_event_error and cron_unschedule_event_error hooks which can be used to trigger additional behaviors when an error occurs.

Props Enchiridion, johnbillion, costdev.
Fixes #56048.

#6 @milana_cap
2 years ago

  • Keywords add-to-field-guide added
Note: See TracTickets for help on using tickets.