[wp-trac] [WordPress Trac] #49327: Add a function that identifies whether WordPress is doing a cron

WordPress Trac noreply at wordpress.org
Thu Jan 30 08:52:22 UTC 2020


#49327: Add a function that identifies whether WordPress is doing a cron
-------------------------+-------------------------
 Reporter:  pikamander2  |       Owner:  (none)
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:
Component:  Cron API     |     Version:  4.8
 Severity:  normal       |  Resolution:  worksforme
 Keywords:               |     Focuses:
-------------------------+-------------------------
Changes (by Clorith):

 * status:  new => closed
 * resolution:   => worksforme
 * version:   => 4.8
 * component:  General => Cron API
 * milestone:  Awaiting Review =>


Comment:

 Hiya,

 There's actually a way to do this already, either with the function
 [https://developer.wordpress.org/reference/functions/wp_doing_cron/
 wp_doing_cron()] (recommended), or looking for the constant `DOING_CRON`
 and seeing if it's `true`.

 As for if it's being performed via CLI, that can be done by looking at the
 PHP native function [https://www.php.net/php_sapi_name php_sapi_name()],
 you'll see `cli` as the output if it's on the command line.

 Since these options already exist, I'm going to mark this ticket as
 `closed`, but if you feel there's something that could be done better,
 please do follow up in here, as it's just a task-management status, and
 conversations can still continue.

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


More information about the wp-trac mailing list