debug('Begin', ['=start' => 'ContactCatSync', '=timed' => 1]); if (!$this->force && !$this->contact_id) { $nextRun = Civi::settings()->get('contactcats_next_run') ?? 0; if (time() < $nextRun) { // not needed yet. Civi::log()->debug("Skipping because not due until " . date('H:i j M Y', $nextRun), ['=' => 'pop']); return; } } $processor = new Processor($this->contact_id); $result->exchangeArray($processor->run()); // Limit to running every 24 hours; we actually want it to be stable within one day. // Schedule for 3am to avoid busy times and DST. $nextRun = strtotime('tomorrow + 180 minutes'); Civi::settings()->set('contactcats_next_run', $nextRun); Civi::settings()->set('contactcats_last_run', time()); Civi::log()->debug("Complete. Scheduling next run after " . date('H:i j M Y', $nextRun), ['=' => 'set']); } }