Open Rahe opened 7 years ago
@Rahe , what was your solution for migrating existing cron tasks to Cavalcade?
Hello @discoinfiltrator ,
the process described on my main message, and run it site by site
So Cavalcade doesn't include a migration of old cron events to Cavalcade tables? Really?
@archon810 , this is a script that my company ran a couple years back to migrate our data:
remove_filter('pre_option_cron', 'HM\Cavalcade\Plugin\Connector\get_cron_array');
remove_filter('pre_update_option_cron', 'HM\Cavalcade\Plugin\Connector\update_cron_array', 10);
$crons = _get_cron_array();
$timestamp = time();
$crons['version'] = 2;
add_option('cron_' . $timestamp, $crons);
unset($crons['version']);
_set_cron_array([]);
add_filter('pre_option_cron', 'HM\Cavalcade\Plugin\Connector\get_cron_array');
add_filter('pre_update_option_cron', 'HM\Cavalcade\Plugin\Connector\update_cron_array', 10, 2);
$count = 0;
foreach ($crons as $timestamp => $cronhooks) {
foreach ($cronhooks as $hook => $keys) {
foreach ($keys as $k => $v) {
if ($v['schedule'] == '' && !isset($v['interval'])) {
$result = wp_schedule_single_event($timestamp, $hook, $v['args']);
if ($result !== false) {
$count++;
}
}
}
}
}
Definitely test it out first - I haven't ran it in some time but I believe it went fine. We only migrated the single events that were previously scheduled as any recurring events would re-schedule themselves.
I can't recall exactly but I think the add_option
call was just to save a backup.
Hello,
My question is about current big installions that will migrate to WP native cron to Calvalcade cron system. Is it possible ? I think we can
but is it safe ?
Regards,