[wp-trac] [WordPress Trac] #60645: Add pre-fire hook for cron

WordPress Trac noreply at wordpress.org
Sun May 19 22:33:08 UTC 2024


#60645: Add pre-fire hook for cron
-------------------------------------------------+-------------------------
 Reporter:  kkmuffme                             |       Owner:  audrasjb
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  6.6
Component:  Cron API                             |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-testing needs-docs   |     Focuses:
  dev-feedback                                   |
-------------------------------------------------+-------------------------

Comment (by peterwilsoncc):

 I don't really see the need for this filter.

 Detecting cron jobs without any callbacks registered can be done via the
 `pre_reschedule_event` filter. If no callbacks are registerd then the hook
 can be removed and rescheduling overridden.

 I think the hooked function for the cron job loading the files is the
 correct approach as each callback should be self-sufficient in the event
 it is fired directly. To avoid duplicate code a plugin an create a helper
 function for the purpose.

 There are also some backward/forward compatibility issues with WP-CLI to
 consider. WP-CLI fires the action directly (view [https://github.com/wp-
 cli/cron-
 command/blob/2108295a2f30de77d3ee70b1a60d1b542c2dfd79/src/Cron_Event_Command.php#L338-L361
 source code]) so there is a risk the new hook would be missed on systems
 running real cron using the CLI.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60645#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list