Automattic\WooCommerce\Internal\BatchProcessing

BatchProcessingController::process_next_batch_for_single_processor()privateWC 1.0

Process a batch for a single processor, and handle any required rescheduling or state cleanup.

Method of the class: BatchProcessingController{}

No Hooks.

Return

null. Nothing.

Usage

// private - for code of main (parent) class only
$result = $this->process_next_batch_for_single_processor( $processor_class_name ): void;
$processor_class_name(string) (required)
Fully qualified class name of the processor.

BatchProcessingController::process_next_batch_for_single_processor() code WC 7.1.1

private function process_next_batch_for_single_processor( string $processor_class_name ): void {
	if ( ! $this->is_enqueued( $processor_class_name ) ) {
		return;
	}

	$batch_processor      = $this->get_processor_instance( $processor_class_name );
	$pending_count_before = $batch_processor->get_total_pending_count();
	$error                = $this->process_next_batch_for_single_processor_core( $batch_processor );
	$pending_count_after  = $batch_processor->get_total_pending_count();
	if ( ( $error instanceof \Exception ) && $pending_count_before === $pending_count_after ) {
		// The batch processing failed and no items were processed:
		// reschedule the processing with a delay, and also throw the error
		// so Action Scheduler will ignore the rescheduling if this happens repeatedly.
		$this->schedule_batch_processing( $processor_class_name, true );
		throw $error;
	}
	if ( $pending_count_after > 0 ) {
		$this->schedule_batch_processing( $processor_class_name );
	} else {
		$this->dequeue_processor( $processor_class_name );
	}
}