[wp-trac] [WordPress Trac] #33863: uksort takes a lot of time with large number of cron events

WordPress Trac noreply at wordpress.org
Mon Sep 14 13:55:20 UTC 2015


#33863: uksort takes a lot of time with large number of cron events
-------------------------+-----------------------------
 Reporter:  geza.miklo   |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  4.3
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 wp-includes/cron.php: 49, 91

 If crons are disabled in wp config:


 {{{
 /** Disable cron jobs */
 define('DISABLE_WP_CRON', true);

 }}}

 Then the events just get collected and collected. We've imported more than
 500k articles, and during that the cron array stored in the options table
 bacame huge. I mean really, really huge.

 On every request it got loaded, parsed and sorted.
 https://secure.phabricator.com/book/phabflavor/article/php_pitfalls
 /#usort-uksort-and-uasort

 Quick fix with filter:


 {{{
 add_filter('schedule_event', function() { return false;});
 add_filter('pre_option_cron', function() { return array(); });
 }}}

 We are using wp-cli to run jobs. For the most needed we've written our own
 command (eg. activating future posts).

 I see three options (two real solution exactly) to fix this error:
 1. Disable collecting cron events where DISABLE_WP_CRON is set to true
 2. Limit the size of the array
 3. Try to avoid sorting (memory problems still will occur)

 Please contact me if any information is needed.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33863>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list