Make WordPress Core

Opened 18 months ago

Closed 15 months ago

Last modified 15 months 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:


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 18 months ago.
56048.2.diff (2.1 KB) - added by costdev 15 months 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)

18 months ago

#1 @johnbillion
17 months 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
17 months ago

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

15 months ago

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

#3 @audrasjb
15 months 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
15 months ago

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

#5 @audrasjb
15 months 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
15 months ago

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