ActionScheduler_WPCLI_QueueRunner::setup()publicWC 1.0

Set up the Queue before processing.

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

Хуков нет.

Возвращает

int. The number of actions that will be run.

Использование

$ActionScheduler_WPCLI_QueueRunner = new ActionScheduler_WPCLI_QueueRunner();
$ActionScheduler_WPCLI_QueueRunner->setup( $batch_size, $hooks, $group, $force );
$batch_size(int) (обязательный)
The batch size to process.
$hooks(массив)
The hooks being used to filter the actions claimed in this batch.
По умолчанию: array()
$group(строка)
The group of actions to claim with this batch.
По умолчанию: ''
$force(true|false)
Whether to force running even with too many concurrent processes.
По умолчанию: false

Код ActionScheduler_WPCLI_QueueRunner::setup() WC 8.7.0

public function setup( $batch_size, $hooks = array(), $group = '', $force = false ) {
	$this->run_cleanup();
	$this->add_hooks();

	// Check to make sure there aren't too many concurrent processes running.
	if ( $this->has_maximum_concurrent_batches() ) {
		if ( $force ) {
			WP_CLI::warning( __( 'There are too many concurrent batches, but the run is forced to continue.', 'woocommerce' ) );
		} else {
			WP_CLI::error( __( 'There are too many concurrent batches.', 'woocommerce' ) );
		}
	}

	// Stake a claim and store it.
	$this->claim = $this->store->stake_claim( $batch_size, null, $hooks, $group );
	$this->monitor->attach( $this->claim );
	$this->actions = $this->claim->get_actions();

	return count( $this->actions );
}