public function handle_unexpected_shutdown() { if ($error = error_get_last()) { if ($error['type'] == E_ERROR) { if (!empty($this->action_id)) { $this->store->mark_failure($this->action_id); do_action('action_scheduler_unexpected_shutdown', $this->action_id, $error); } } $this->store->release_claim($this->claim); } }
public function handle_unexpected_shutdown() { if ($error = error_get_last()) { if (in_array($error['type'], array(E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR))) { if (!empty($this->action_id)) { $this->store->mark_failure($this->action_id); do_action('action_scheduler_unexpected_shutdown', $this->action_id, $error); } } $this->store->release_claim($this->claim); } }
public function mark_failures() { $timeout = apply_filters('action_scheduler_failure_period', $this->five_minutes); if ($timeout < 0) { return; } $cutoff = new DateTime($timeout . ' seconds ago'); $actions_to_reset = $this->store->query_actions(array('status' => ActionScheduler_Store::STATUS_RUNNING, 'modified' => $cutoff, 'modified_compare' => '<=', 'claimed' => TRUE, 'per_page' => apply_filters('action_scheduler_cleanup_batch_size', 20))); foreach ($actions_to_reset as $action_id) { $this->store->mark_failure($action_id); do_action('action_scheduler_failed_action', $action_id); } }
public function process_action($action_id) { try { do_action('action_scheduler_before_execute', $action_id); $action = $this->store->fetch_action($action_id); $this->store->log_execution($action_id); $action->execute(); do_action('action_scheduler_after_execute', $action_id); $this->store->mark_complete($action_id); } catch (Exception $e) { $this->store->mark_failure($action_id); do_action('action_scheduler_failed_execution', $action_id, $e); } $this->schedule_next_instance($action); }