ActionScheduler_Abstract_QueueRunner::recurring_action_is_consistently_failing()privateWC 1.0

Determine if the specified recurring action has been consistently failing.

Метод класса: ActionScheduler_Abstract_QueueRunner{}




// private - только в коде основоного (родительского) класса
$result = $this->recurring_action_is_consistently_failing( $action, $action_id );
$action(ActionScheduler_Action) (обязательный)
The recurring action to be rescheduled.
$action_id(int) (обязательный)
The ID of the recurring action.

Код ActionScheduler_Abstract_QueueRunner::recurring_action_is_consistently_failing() WC 9.0.2

private function recurring_action_is_consistently_failing( ActionScheduler_Action $action, $action_id ) {
	 * Controls the failure threshold for recurring actions.
	 * Before rescheduling a recurring action, we look at its status. If it failed, we then check if all of the most
	 * recent actions (upto the threshold set by this filter) sharing the same hook have also failed: if they have,
	 * that is considered consistent failure and a new instance of the action will not be scheduled.
	 * @param int $failure_threshold Number of actions of the same hook to examine for failure. Defaults to 5.
	$consistent_failure_threshold = (int) apply_filters( 'action_scheduler_recurring_action_failure_threshold', 5 );

	// This query should find the earliest *failing* action (for the hook we are interested in) within our threshold.
	$query_args = array(
		'hook'         => $action->get_hook(),
		'status'       => ActionScheduler_Store::STATUS_FAILED,
		'date'         => date_create( 'now', timezone_open( 'UTC' ) )->format( 'Y-m-d H:i:s' ),
		'date_compare' => '<',
		'per_page'     => 1,
		'offset'       => $consistent_failure_threshold - 1

	$first_failing_action_id = $this->store->query_actions( $query_args );

	// If we didn't retrieve an action ID, then there haven't been enough failures for us to worry about.
	if ( empty( $first_failing_action_id ) ) {
		return false;

	// Now let's fetch the first action (having the same hook) of *any status* within the same window.
	unset( $query_args['status'] );
	$first_action_id_with_the_same_hook = $this->store->query_actions( $query_args );

	 * If a recurring action is assessed as consistently failing, it will not be rescheduled. This hook provides a
	 * way to observe and optionally override that assessment.
	 * @param bool                   $is_consistently_failing If the action is considered to be consistently failing.
	 * @param ActionScheduler_Action $action                  The action being assessed.
	return (bool) apply_filters(
		$first_action_id_with_the_same_hook === $first_failing_action_id,