[wp-trac] [WordPress Trac] #24160: ALTERNATE_WP_CRON runs wp_cron() too early

WordPress Trac noreply at wordpress.org
Tue Dec 15 03:49:57 UTC 2020


#24160: ALTERNATE_WP_CRON runs wp_cron() too early
-------------------------------------------+----------------------------
 Reporter:  r-a-y                          |       Owner:  peterwilsoncc
     Type:  defect (bug)                   |      Status:  assigned
 Priority:  normal                         |   Milestone:  5.7
Component:  Cron API                       |     Version:  3.4
 Severity:  normal                         |  Resolution:
 Keywords:  has-patch early needs-refresh  |     Focuses:
-------------------------------------------+----------------------------

Comment (by peterwilsoncc):

 Doing some research to determine backward compatibility issues.

 https://wpdirectory.net/search/01ESJ720E4PB7VBTX7YMYX9JTB

 * ten plugins run `remove_action( 'init', 'wp_cron' )`
 * the three most popular have 300K+, 40K+, and 20K+ installs

 I do like @prettyboymp's suggestion above of moving the `wp_loaded`
 function to match the execution point in which alternative cron runs to
 the standard wp-cron. It would probably need to run late on that too (ie,
 priority `20` or higher).

 ---

 @johnbillion I think it's safest to go with some ugly code to maintain
 backward compatibility. What are your thoughts on the following?

 `wp_cron()` renamed to `_wp_cron()`, `wp_cron_loaded()` or similar.

 `wp_cron()` continues to run on `init, 10` and then looks something like
 this:

 {{{
 function wp_cron() {
   if ( did_action( 'wp_loaded' ) {
     return _wp_cron();
   }

   add_action( 'wp_loaded', '_wp_cron', 20 );
 }
 }}}

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


More information about the wp-trac mailing list