Title: Plugin breaks cron on multiple plugins
Last modified: August 30, 2016

---

# Plugin breaks cron on multiple plugins

 *  Resolved [Mark](https://wordpress.org/support/users/markob17/)
 * (@markob17)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/)
 * Been using your plugin for many years without any problems but suddenly I noticed
   it causes problems with the cronjob functionality of a few plugins in use. The
   two plugins I use are WP-Cron Events and Woozone Amazon Associates plugin.
 * When your plugin is enabled, it prevents WP-Cron from being able to manage cronjobs(
   some custom ones don’t work) and it breaks WooZone Amazon Associates plugin cronjob
   functionality, prevents it from working altogether.
 * When I disable your plugin everything works as intended with both these plugins.
   Any ideas? I’d like to continue using your plugin but need my cronjobs to work.
 * Regards,
    Mark
 * [https://wordpress.org/plugins/rvg-optimize-database/](https://wordpress.org/plugins/rvg-optimize-database/)

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/page/2/?output_format=md)

 *  Plugin Contributor [cageehv](https://wordpress.org/support/users/cageehv/)
 * (@cageehv)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827568)
 * Hey Mark,
 * I cannot find a plugin called ‘WP-Cron Events’. Do you, by any chance, mean ‘
   WP Crontrol’?
 * I installed ‘WP Crontrol’ and it works flawless with my plugin.
 * I didn’t try the other plugin ‘WooZone Amazon Associates’ yet.
 * Do you also have problems if you don’t use the Optimize Database scheduler? Or
   only if you put it into the Cron?
 * peace,
    Rolf
 *  Thread Starter [Mark](https://wordpress.org/support/users/markob17/)
 * (@markob17)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827575)
 * Hi Rolf,
 * Sorry about that, the plugin is called WP Crontrol. Issue occurs whether or not
   I have optimize database scheduler enabled. Maybe this is a conflict with another
   plugin I am using, I will re-test right now by disabling everything except wp
   crontrol and your plugin and let you know the results. Thanks for the quick followup.
   Talk soon.
 * Regards,
    Mark
 *  Thread Starter [Mark](https://wordpress.org/support/users/markob17/)
 * (@markob17)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827576)
 * Hi Rolf,
 * Just set my site to default wordpress 2015 theme, disabled every plugin except
   your plugin and WP Crontrol. Still breaks things. Did you test by going to settings
   in dashboard, choosing cron schedules, and setting up a test cron? When your 
   plugin is enabled, all test crons vanish from view, normally you can view and
   manage them by deleting with the x next to the custom cron events shown in the
   list. When I disable your plugin, the test crons show back up.
 * Mark
 *  Plugin Contributor [cageehv](https://wordpress.org/support/users/cageehv/)
 * (@cageehv)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827586)
 * Hey Mark,
 * Thanks for the feedback!
 * Okay, so you add a new Cron entry by hand, using WP Crontrol.
    and when my plugin
   is enabled, it doesn’t show.
 * Got it! I’ll try, see what happens and report back.
 * peace,
    Rolf
 *  Plugin Contributor [cageehv](https://wordpress.org/support/users/cageehv/)
 * (@cageehv)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827590)
 * Hey Mark,
 * Hummmmmm…
    I manually scheduled a task from one of my other plugins (using WP
   Crontrol) and set it to run every five minutes (a schedule the Optimize Database
   plugin adds for testing purposes).
 * It runs nicely, every 5 minutes (with Optimize Database enabled).
 * So, I’m puzzled 😉
 * peace,
    Rolf
 *  Thread Starter [Mark](https://wordpress.org/support/users/markob17/)
 * (@markob17)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827592)
 * I’m puzzled as well. I haven’t had any issues with your plugin for years. The
   only thing difference with my new website is that InnoDB is the database default.
   Could that be a problem?
 *  [awhig](https://wordpress.org/support/users/awhig/)
 * (@awhig)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827722)
 * I’m having an issue as well with another plugin. WP Missed Schedule Fix Future
   Posts Failed is no longer working.
 * [https://wordpress.org/plugins/wp-missed-schedule/](https://wordpress.org/plugins/wp-missed-schedule/)
 * I look at the cron events or what’s in cron and the schedules it defined are 
   not present and it’s event is not registered.
 * These are the Schedules available when I disable ODB.
 *     ```
       Available schedules
   
       Every Ten Minutes, every 10 mins
       [W3TC] Object Cache file GC (every 3600 seconds), every 1 hour
       [W3TC] Page Cache file GC (every 3600 seconds), every 1 hour
       [W3TC] Page Cache prime (every 900 seconds), every 15 mins
       [W3TC] CDN queue process (every 900 seconds), every 15 mins
       [W3TC] CDN auto upload (every 3600 seconds), every 1 hour
       [W3TC] Minify file GC (every 86400 seconds), every 1 day
       Once Hourly, every 1 hour
       Twice Daily, every 12 hours
       Once Daily, every 1 day
       ```
   
 * When I enable the plugin, all of the custom schedules disappear, except for the
   ones the ODB plugin creates…
 *     ```
       Available schedules
   
       Once Weekly, every 1 week
       Every Five Minutes, every 5 mins
       Once Hourly, every 1 hour
       Twice Daily, every 12 hours
       Once Daily, every 1 day
       ```
   
 * So I believe this causes all of plugins that rely on a custom schedule to break.
 * Rich
 *  [awhig](https://wordpress.org/support/users/awhig/)
 * (@awhig)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827723)
 * I believe the code that registers the schedules is not correct.
 * From [https://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules](https://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules)
 *     ```
       function my_add_weekly( $schedules ) {
       	// add a 'weekly' schedule to the existing set
       	$schedules['weekly'] = array(
       		'interval' => 604800,
       		'display' => __('Once Weekly')
       	);
       	return $schedules;
       }
       add_filter( 'cron_schedules', 'my_add_weekly' );
       ```
   
 * What is done in the plugin:
 *     ```
       // ADD EXTRA CRON SCHEDULES
       		add_filter('cron_schedules', array(&$this, 'odb_extra_cron_schedules'));
   
       function odb_extra_cron_schedules()
       	{
       		global $odb_class;
   
       		$schedules['weekly'] = array(
       			'interval' => 604800,
       			'display'  => __('Once Weekly', $odb_class->odb_txt_domain)
       		);
       		// FOR DEBUGGING
       		$schedules['fiveminutes'] = array(
       			'interval' => 300,
       			'display'  => __('Every Five Minutes', $odb_class->odb_txt_domain)
       		);
       		return $schedules;
       	} // odb_extra_cron_schedules()
       ```
   
 * The method is not taking in the passed in $schedules objects. It is creating 
   its own.
 *  [awhig](https://wordpress.org/support/users/awhig/)
 * (@awhig)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827724)
 * I changed the line to
 * `function odb_extra_cron_schedules($schedules)`
 * And now all the custom schedules created by my other plugins W3TC, Missed Posts,
   etc. are now registered properly.
 * I still don’t see the event from missed posts showing up in the events list, 
   so I will investigate further.
 * Update ***
 * I deactivated, then reactivated the WP Missed Schedule Fix Future Posts Failed
   plugin after applying my fix to this plugin and now the event is appearing properly.
 * Rich
 *  Thread Starter [Mark](https://wordpress.org/support/users/markob17/)
 * (@markob17)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827725)
 * Very interesting, thank you for sharing your findings Rich. I knew I wasn’t crazy
   as the same thing happens to me in that all the custom schedules disappear when
   Optimize Database after Deleting Revisions is enabled, and reappear when it is
   disabled. I don’t like to edit a plugin authors plugin for I believe they should
   be the ones fixing something broken but I will have to test out what you just
   put here for the author didn’t fine an issue himself.
 *  Thread Starter [Mark](https://wordpress.org/support/users/markob17/)
 * (@markob17)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827726)
 * Update:
 * Just added the $schedules value to the plugin file rvg-optimize-database/classes/
   odb-scheduler.php per Rich’s findings and now my custom cron jobs show up as 
   intended. I’m waiting for my next cronjob to kick in automatically when the Woozone
   plugin updates at the next scheduled time before I can say with certainty my 
   problem is fixed but so far it looks like it is.
 * Rich, thank you very much for finding this solution. I’m not sure if Rolf is 
   still subscribed to this support thread but I hope he gets wind of your findings
   and digs a little deeper.
 * Best Regards,
    Mark
 *  [DrProtocols](https://wordpress.org/support/users/drprotocols/)
 * (@drprotocols)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827733)
 * This is a definite plugin bug which is simply fixed as per the details from Rich.
 * I think the plugin author maybe misunderstood the plugin bug and thought it was
   something to do with cron events not running rather than schedule interval definitions
   not being available.
 * The confusing thing with this particular plugin bug is that the effect can vary
   based on the order of plugin initialisation by WordPress since this determines
   the order in which filters adding additional schedule intervals are executed.
 * What should happen is that as each plugin filter runs it takes the existing schedules
   array passed as a parameter by WordPress and adds custom schedules to it and 
   then returns the updated array.
 * What this plugin is currently doing is _not_ taking the existing array (which
   it should take as the parameter of the filter function call) but effectively 
   defining a new schedules array, adding it’s own schedule definitions and then
   returning that new array.
 * The effect is that any filter function for other plugins that are executed _before_
   this plugin filter function will have the schedules they have added discarded
   but any plugin filter functions that run _after_ this plugin filter will have
   their schedule definitions added to the new schedules array that this plugin 
   created.
 * Apart from fixing the plugin code as Rich indicates the other workaround is to
   try and force this plugin to be the first plugin that WordPress initializes (
   loads) and so its filter will be executed first and hopefully you would then 
   get the additional custom schedules from other plugins as their filters would
   run after that of this plugin. But this is _not_ a solution but just a workaround
   because the core WordPress schedules that WordPress populates into the original
   schedules array will still be lost.
 *  [awhig](https://wordpress.org/support/users/awhig/)
 * (@awhig)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827735)
 * [@mark](https://wordpress.org/support/users/mark/),
 * I found that I had to deactivate/reactivate or resave the settings of some of
   my plugins in order for the plugin to reapply its event, after I fixed the bug.
   If your event isn’t showing up try this.
 * Rich
 *  Plugin Contributor [cageehv](https://wordpress.org/support/users/cageehv/)
 * (@cageehv)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827737)
 * Hey guys,
 * I fixed the Cron Schedule issue and released v4.0.3.
 * Thanks for all your feedback and testing!
 * peace,
    Rolf
 *  [awhig](https://wordpress.org/support/users/awhig/)
 * (@awhig)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/#post-6827738)
 * Rolf,
 * Thanks for the quick response!
 * Rich

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/page/2/?output_format=md)

The topic ‘Plugin breaks cron on multiple plugins’ is closed to new replies.

 * ![](https://ps.w.org/rvg-optimize-database/assets/icon-256x256.png?rev=3350597)
 * [Optimize Database after Deleting Revisions](https://wordpress.org/plugins/rvg-optimize-database/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/rvg-optimize-database/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/rvg-optimize-database/)
 * [Active Topics](https://wordpress.org/support/plugin/rvg-optimize-database/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/rvg-optimize-database/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/rvg-optimize-database/reviews/)

 * 17 replies
 * 4 participants
 * Last reply from: [cageehv](https://wordpress.org/support/users/cageehv/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/plugin-breaks-cron-on-multiple-plugins/page/2/#post-6827742)
 * Status: resolved