WordPress.org

Make WordPress Core

Opened 6 years ago

Last modified 9 months ago

#28635 reopened feature request

Add status codes and hooks to wp-cron.php

Reported by: westonruter Owned by: chriscct7
Milestone: Future Release 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 6 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 6 years ago.
Fix order of operations in request validity check
28635.2.patch (7.9 KB) - added by jrtashjian 4 years ago.

Download all attachments as: .zip

Change History (7)

@westonruter
6 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
6 years ago

Fix order of operations in request validity check

#1 @chriscct7
4 years ago

  • Keywords needs-refresh added

@jrtashjian
4 years ago

#2 @jrtashjian
4 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
4 years ago

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

#5 @peterwilsoncc
13 months ago

  • Milestone set to Future Release
  • Status changed from reviewing to reopened

This is worth some investigation so I'm reopening this and putting it down for a future release. The Cron component has a bit of a backlog, so I won't give a timeframe for now as it would set a false expectation.

Note: See TracTickets for help on using tickets.