ActionScheduler_WPCLI_QueueRunner::runpublicWC 1.0

Process actions in the queue.

Method of the class: ActionScheduler_WPCLI_QueueRunner{}

Returns

Int. The number of actions processed.

Usage

$ActionScheduler_WPCLI_QueueRunner = new ActionScheduler_WPCLI_QueueRunner();
$ActionScheduler_WPCLI_QueueRunner->run( $context );
$context(string)
Optional runner context.
Default: 'WP CLI'

ActionScheduler_WPCLI_QueueRunner::run() code WC 11.0.1

public function run( $context = 'WP CLI' ) {
	do_action( 'action_scheduler_before_process_queue' );
	$this->setup_progress_bar();

	$claim_id = $this->claim->get_id();
	foreach ( $this->actions as $action_id ) {
		// Bail if we lost the claim.
		if ( $claim_id !== $this->store->get_claim_id( $action_id ) ) {
			WP_CLI::warning( __( 'The claim has been lost. Aborting current batch.', 'woocommerce' ) );
			break;
		}

		$this->process_action( $action_id, $context );
		$this->progress_bar->tick();
	}

	$completed = $this->progress_bar->current();
	$this->progress_bar->finish();
	$this->store->release_claim( $this->claim );
	do_action( 'action_scheduler_after_process_queue' );

	return $completed;
}