Automattic\WP\Cron_Control\Events::update_event_record PHP Метод

update_event_record() приватный Метод

Mark an event completed, and reschedule when requested
private update_event_record ( $event )
    private function update_event_record($event)
    {
        if (false !== $event['schedule']) {
            // Get the existing ID
            $job_id = Cron_Options_CPT::instance()->job_exists($event['timestamp'], $event['action'], $event['instance'], true);
            // Re-implements much of the logic from `wp_reschedule_event()`
            $schedules = wp_get_schedules();
            $interval = 0;
            // First, we try to get it from the schedule
            if (isset($schedules[$event['schedule']])) {
                $interval = $schedules[$event['schedule']]['interval'];
            }
            // Now we try to get it from the saved interval, in case the schedule disappears
            if (0 == $interval) {
                $interval = $event['interval'];
            }
            // If we have an interval, update the existing event entry
            if (0 != $interval) {
                // Determine new timestamp, according to how `wp_reschedule_event()` does
                $now = time();
                $new_timestamp = $event['timestamp'];
                if ($new_timestamp >= $now) {
                    $new_timestamp = $now + $interval;
                } else {
                    $new_timestamp = $now + ($interval - ($now - $new_timestamp) % $interval);
                }
                // Build the expected arguments format
                $event_args = array('schedule' => $event['schedule'], 'args' => $event['args'], 'interval' => $interval);
                // Update CPT store
                Cron_Options_CPT::instance()->create_or_update_job($new_timestamp, $event['action'], $event_args, $job_id);
                // If the event could be rescheduled, don't then delete it :)
                if (is_int($job_id) && $job_id > 0) {
                    return;
                }
            }
        }
        // Either event doesn't recur, or the interval couldn't be determined
        Cron_Options_CPT::instance()->mark_job_completed($event['timestamp'], $event['action'], $event['instance']);
    }