WooCommerce Code Reference

PostsToOrdersMigrationController

This is the main class used to perform the complete migration of orders from the posts table to the custom orders table.

Table of Contents

LOGS_SOURCE_NAME  = 'posts-to-orders-migration'
The source name to use for logs.
$all_migrators  : array<string|int, TableMigrator>
Array of objects used to perform the migration.
$error_logger  : WC_Logger
Error logger for migration errors.
__construct()  : mixed
PostsToOrdersMigrationController constructor.
get_migrated_meta_keys()  : array<string|int, string>
Helper method to get migrated keys for all the tables in this controller.
migrate_order()  : void
Migrates an order from the posts table to the custom orders tables.
migrate_orders()  : void
Migrates a set of orders from the posts table to the custom orders tables.
verify_migrated_orders()  : array<string|int, mixed>
Verify whether the given order IDs were migrated properly or not.
commit_transaction()  : bool
Commit the current database transaction.
db_query()  : bool
Execute a database query and log any errors.
handle_migration_error()  : mixed
Log migration errors if any.
maybe_start_transaction()  : bool|null
Start a database transaction if the configuration mandates so.
rollback_transaction()  : bool
Rollback the current database transaction.

Constants

Properties

Methods

verify_migrated_orders()

Verify whether the given order IDs were migrated properly or not.

public verify_migrated_orders(array<string|int, mixed> $order_post_ids) : array<string|int, mixed>
Parameters
$order_post_ids : array<string|int, mixed>

Order IDs.

Return values
array<string|int, mixed>Array of failed IDs along with columns.

db_query()

Execute a database query and log any errors.

private db_query(string $query[, bool $supress_errors = false ]) : bool
Parameters
$query : string

The SQL query to execute.

$supress_errors : bool = false

Whether to suppress errors.

Return values
boolTrue if the query succeeded, false if there were errors.

handle_migration_error()

Log migration errors if any.

private handle_migration_error(array<string|int, mixed> $order_post_ids, array<string|int, mixed> $errors, Exception|null $exception, bool|null $using_transactions, string $name) : mixed
Parameters
$order_post_ids : array<string|int, mixed>

List of post IDs of the orders to migrate.

$errors : array<string|int, mixed>

List of errors to log.

$exception : Exception|null

Exception to log.

$using_transactions : bool|null

Whether transactions were used.

$name : string

Name of the migrator.

Return values
mixed

maybe_start_transaction()

Start a database transaction if the configuration mandates so.

private maybe_start_transaction() : bool|null
Tags
throws
Exception

If the transaction isolation level is invalid.

Return values
bool|nullTrue if transaction started, false if transactions won't be used, null if transaction failed to start.