ActionScheduler_QueueCleaner::mark_failures()publicWC 1.0

Mark actions that have been running for more than a given time limit as failed, based on the assumption some uncatachable and unloggable fatal error occurred during processing.

When called by ActionScheduler_Abstract_QueueRunner::run_cleanup(), the time limit passed as a parameter is 10x the time limit used for queue processing.

Method of the class: ActionScheduler_QueueCleaner{}

Return

null. Nothing (null).

Usage

$ActionScheduler_QueueCleaner = new ActionScheduler_QueueCleaner();
$ActionScheduler_QueueCleaner->mark_failures( $time_limit );
$time_limit(int)
The number of seconds to allow an action to run before it is considered to have failed.
Default: 300 (5 minutes)

ActionScheduler_QueueCleaner::mark_failures() code WC 8.6.1

public function mark_failures( $time_limit = 300 ) {
	$timeout = apply_filters( 'action_scheduler_failure_period', $time_limit );
	if ( $timeout < 0 ) {
		return;
	}
	$cutoff = as_get_datetime_object($timeout.' seconds ago');
	$actions_to_reset = $this->store->query_actions( array(
		'status'           => ActionScheduler_Store::STATUS_RUNNING,
		'modified'         => $cutoff,
		'modified_compare' => '<=',
		'per_page'         => $this->get_batch_size(),
		'orderby'          => 'none',
	) );

	foreach ( $actions_to_reset as $action_id ) {
		$this->store->mark_failure( $action_id );
		do_action( 'action_scheduler_failed_action', $action_id, $timeout );
	}
}