ActionScheduler_QueueCleaner::reset_timeoutspublicWC 1.0

Unclaim pending actions that have not been run within a given time limit.

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{}

Returns

null. Nothing (null).

Usage

$ActionScheduler_QueueCleaner = new ActionScheduler_QueueCleaner();
$ActionScheduler_QueueCleaner->reset_timeouts( $time_limit );
$time_limit(int)
The number of seconds to allow a queue to run before unclaiming its pending actions.
Default: 300 (5 minutes)

ActionScheduler_QueueCleaner::reset_timeouts() code WC 9.8.5

public function reset_timeouts( $time_limit = 300 ) {
	$timeout = apply_filters( 'action_scheduler_timeout_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_PENDING,
			'modified'         => $cutoff,
			'modified_compare' => '<=',
			'claimed'          => true,
			'per_page'         => $this->get_batch_size(),
			'orderby'          => 'none',
		)
	);

	foreach ( $actions_to_reset as $action_id ) {
		$this->store->unclaim_action( $action_id );
		do_action( 'action_scheduler_reset_action', $action_id );
	}
}