Automattic\WooCommerce\Internal\DataStores\Orders

LegacyDataCleanup::process_batch()publicWC 1.0

Process data for current batch.

Method of the class: LegacyDataCleanup{}

No Hooks.

Return

null. Nothing (null).

Usage

$LegacyDataCleanup = new LegacyDataCleanup();
$LegacyDataCleanup->process_batch( $batch ): void;
$batch(array) (required)
Batch details.

LegacyDataCleanup::process_batch() code WC 9.3.3

public function process_batch( array $batch ): void {
	// This is a destructive operation, so check if we need to bail out just in case.
	if ( ! $this->can_run() ) {
		$this->toggle_flag( false );
		return;
	}

	$batch_failed = true;

	foreach ( $batch as $order_id ) {
		try {
			$this->legacy_handler->cleanup_post_data( absint( $order_id ) );
			$batch_failed = false;
		} catch ( \Exception $e ) {
			$this->error_logger->error(
				sprintf(
					// translators: %1$d is an order ID, %2$s is an error message.
					__( 'Order %1$d legacy data could not be cleaned up during batch process. Error: %2$s', 'woocommerce' ),
					$order_id,
					$e->getMessage()
				)
			);
		}
	}

	if ( $batch_failed ) {
		$this->error_logger->error( __( 'Order legacy cleanup failed for an entire batch of orders. Aborting cleanup.', 'woocommerce' ) );
	}

	if ( ! $this->orders_pending() || $batch_failed ) {
		$this->toggle_flag( false );
	}
}