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 (null).

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 8.7.0

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 );
	$error           = $this->process_next_batch_for_single_processor_core( $batch_processor );
	$still_pending   = count( $batch_processor->get_next_batch_to_process( 1 ) ) > 0;
	if ( ( $error instanceof \Exception ) ) {
		// 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 ( $still_pending ) {
		$this->schedule_batch_processing( $processor_class_name );
	} else {
		$this->dequeue_processor( $processor_class_name );
	}
}