Skip to content

Commit

Permalink
Validate cache_cleanup_schedule and reset if schedule no longer exists
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed Dec 7, 2015
1 parent dbbb273 commit 861cc45
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/includes/classes/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ public function setup()
if (!is_multisite() || is_main_site()) { // Main site only.
add_filter('cron_schedules', array($this, 'extendCronSchedules'));

if ($_schedules = wp_get_schedules() && !isset($_schedules[$this->options['cache_cleanup_schedule']])) { // Schedule no longer exists; reset to default
$this->updateOptions(array('cache_cleanup_schedule' => $this->default_options['cache_cleanup_schedule'], 'crons_setup' => '0'));
unset($_schedules);
}
if ((integer) $this->options['crons_setup'] < 1449411081 || substr($this->options['crons_setup'], 10) !== '-'.__NAMESPACE__.'-'.$this->options['cache_cleanup_schedule']) {
wp_clear_scheduled_hook('_cron_'.GLOBAL_NS.'_cleanup');
wp_schedule_event(time() + 60, $this->options['cache_cleanup_schedule'], '_cron_'.GLOBAL_NS.'_cleanup');
Expand Down

0 comments on commit 861cc45

Please sign in to comment.