Automattic\WooCommerce\Database\Migrations\CustomOrderTable

PostsToOrdersMigrationController::handle_migration_error()privateWC 1.0

Log migration errors if any.

Method of the class: PostsToOrdersMigrationController{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->handle_migration_error( $order_post_ids, $errors, ?\Exception $exception, ?bool $using_transactions, $name );
$order_post_ids(array) (required)
List of post IDs of the orders to migrate.
$errors(array) (required)
List of errors to log.
?\Exception $exception (required)
-
?bool $using_transactions (required)
-
$name(string) (required)
Name of the migrator.

PostsToOrdersMigrationController::handle_migration_error() code WC 9.7.1

private function handle_migration_error( array $order_post_ids, array $errors, ?\Exception $exception, ?bool $using_transactions, string $name ) {
	$batch = ArrayUtil::to_ranges_string( $order_post_ids );

	if ( null !== $exception ) {
		$exception_class = get_class( $exception );
		$this->error_logger->error(
			"$name: when processing ids $batch: ($exception_class) {$exception->getMessage()}, {$exception->getTraceAsString()}",
			array(
				'source'    => self::LOGS_SOURCE_NAME,
				'ids'       => $order_post_ids,
				'exception' => $exception,
			)
		);
	}

	foreach ( $errors as $error ) {
		$this->error_logger->error(
			"$name: when processing ids $batch: $error",
			array(
				'source' => self::LOGS_SOURCE_NAME,
				'ids'    => $order_post_ids,
				'error'  => $error,
			)
		);
	}

	if ( $using_transactions ) {
		$this->rollback_transaction();
	} else {
		$this->maybe_clear_order_datastore_cache_for_ids( $order_post_ids );
	}
}