Action_Scheduler\WP_CLI

Migration_Command::migrate()publicWC 1.0

Process the data migration.

Method of the class: Migration_Command{}

No Hooks.

Return

null. Nothing (null).

Usage

$Migration_Command = new Migration_Command();
$Migration_Command->migrate( $positional_args, $assoc_args );
$positional_args(array) (required)
Required for WP CLI. Not used in migration.
$assoc_args(array) (required)
Optional arguments.

Migration_Command::migrate() code WC 8.7.0

public function migrate( $positional_args, $assoc_args ) {
	$this->init_logging();

	$config = $this->get_migration_config( $assoc_args );
	$runner = new Runner( $config );
	$runner->init_destination();

	$batch_size = isset( $assoc_args[ 'batch-size' ] ) ? (int) $assoc_args[ 'batch-size' ] : 100;
	$free_on    = isset( $assoc_args[ 'free-memory-on' ] ) ? (int) $assoc_args[ 'free-memory-on' ] : 50;
	$sleep      = isset( $assoc_args[ 'pause' ] ) ? (int) $assoc_args[ 'pause' ] : 0;
	\ActionScheduler_DataController::set_free_ticks( $free_on );
	\ActionScheduler_DataController::set_sleep_time( $sleep );

	do {
		$actions_processed     = $runner->run( $batch_size );
		$this->total_processed += $actions_processed;
	} while ( $actions_processed > 0 );

	if ( ! $config->get_dry_run() ) {
		// let the scheduler know that there's nothing left to do
		$scheduler = new Scheduler();
		$scheduler->mark_complete();
	}

	WP_CLI::success( sprintf( '%s complete. %d actions processed.', $config->get_dry_run() ? 'Dry run' : 'Migration', $this->total_processed ) );
}