Automattic\WooCommerce\Internal\BatchProcessing

BatchProcessingController::process_next_batch_for_single_processor_core()privateWC 1.0

Process a batch for a single processor, updating state and logging any error.

Method of the class: BatchProcessingController{}

No Hooks.

Return

null|\Exception. Exception if error occurred, null otherwise.

Usage

// private - for code of main (parent) class only
$result = $this->process_next_batch_for_single_processor_core( $batch_processor ): ?\Exception;
$batch_processor(BatchProcessorInterface) (required)
Batch processor instance.

BatchProcessingController::process_next_batch_for_single_processor_core() code WC 7.1.0

private function process_next_batch_for_single_processor_core( BatchProcessorInterface $batch_processor ): ?\Exception {
	$details    = $this->get_process_details( $batch_processor );
	$time_start = microtime( true );
	$batch      = $batch_processor->get_next_batch_to_process( $details['current_batch_size'] );
	if ( empty( $batch ) ) {
		return null;
	}
	try {
		$batch_processor->process_batch( $batch );
		$time_taken = microtime( true ) - $time_start;
		$this->update_processor_state( $batch_processor, $time_taken );
	} catch ( \Exception $exception ) {
		$time_taken = microtime( true ) - $time_start;
		$this->log_error( $exception, $batch_processor, $batch );
		$this->update_processor_state( $batch_processor, $time_taken, $exception );
		return $exception;
	}
	return null;
}