Automattic\WooCommerce\Database\Migrations\CustomOrderTable
PostsToOrdersMigrationController::do_orders_migration_step()
Performs one step of the migration for a set of order posts using one given migration class. All database errors and exceptions are logged.
Метод класса: PostsToOrdersMigrationController{}
Хуков нет.
Возвращает
true|false
. True if errors were logged, false otherwise.
Использование
// private - только в коде основоного (родительского) класса $result = $this->do_orders_migration_step( $migration_class, $order_post_ids ): bool;
- $migration_class(объект) (обязательный)
- The migration class to use, must have a process_migration_batch_for_ids(array of ids) method.
- $order_post_ids(массив) (обязательный)
- List of post IDs of the orders to migrate.
Код PostsToOrdersMigrationController::do_orders_migration_step() PostsToOrdersMigrationController::do orders migration step WC 7.7.2
private function do_orders_migration_step( object $migration_class, array $order_post_ids ): bool { $result = $migration_class->process_migration_batch_for_ids( $order_post_ids ); $errors = array_unique( $result['errors'] ); $exception = $result['exception']; if ( null === $exception && empty( $errors ) ) { return false; } $migration_class_name = ( new \ReflectionClass( $migration_class ) )->getShortName(); $batch = ArrayUtil::to_ranges_string( $order_post_ids ); if ( null !== $exception ) { $exception_class = get_class( $exception ); $this->error_logger->error( "$migration_class_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( "$migration_class_name: when processing ids $batch: $error", array( 'source' => self::LOGS_SOURCE_NAME, 'ids' => $order_post_ids, 'error' => $error, ) ); } return true; }