WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 2 years ago

#28635 reviewing feature request

Add status codes and hooks to wp-cron.php

Reported by: westonruter Owned by: chriscct7
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Cron API Keywords: has-patch
Focuses: Cc:

Description

I've been debugging a site problem which turned out to be one of the cron actions resulting in a memory limit breach, and so PHP did a fatal error in the middle of the cron loop. (It's a high-traffic site so it has DISABLE_WP_CRON with system cron pinging wp-cron.php every minute.) There is currently very little debugging hooks provided in wp-cron.php to help diagnose why and where a scheduled event hook is failing.

Some ideas for how wp-cron.php could be improved to facilitate debugging (and also to help with general logging):

  • Return a status message pinpointing at which point wp-cron.php exited
  • Return relevant HTTP status codes
  • Allow die behavior to be overridden, similarly to how wp_die() is used elsewhere
  • Add hooks before before and after each level in the triple-nested crons loop.

Attachments (3)

28635.diff (6.3 KB) - added by westonruter 3 years ago.
Echo status codes from wp-cron.php. Use _ajax_wp_die_handler for DOING_CRON too. Introduce filterable wp_cron_exit_handler with HTTP status codes. Add hooks for cron loops. Commits:https://github.com/x-team/wordpress-develop/compare/master...d6450f9 PR: https://github.com/x-team/wordpress-develop/pull/21
28635.1.diff (6.3 KB) - added by westonruter 3 years ago.
Fix order of operations in request validity check
28635.2.patch (7.9 KB) - added by jrtashjian 2 years ago.

Download all attachments as: .zip

Change History (6)

@westonruter
3 years ago

Echo status codes from wp-cron.php. Use _ajax_wp_die_handler for DOING_CRON too. Introduce filterable wp_cron_exit_handler with HTTP status codes. Add hooks for cron loops. Commits:https://github.com/x-team/wordpress-develop/compare/master...d6450f9 PR: https://github.com/x-team/wordpress-develop/pull/21

@westonruter
3 years ago

Fix order of operations in request validity check

#1 @chriscct7
2 years ago

  • Keywords needs-refresh added

@jrtashjian
2 years ago

#2 @jrtashjian
2 years ago

  • Keywords needs-refresh removed

The patch has been refreshed against the latest trunk. I've also went through and documented the various parts that had @todo docs in the comments.

I recently submitted a new patch for #18471 but I believe this same ticket is related and accomplishes the task better.

#3 @chriscct7
2 years ago

  • Owner set to chriscct7
  • Status changed from new to reviewing
Note: See TracTickets for help on using tickets.