Migration Runner

Action_SchedulerMigrationRunner executes the actual migration of actions and logs from the source store to the destination store.

Since: 3.0.0
Source: classes/migration/Runner.php

Purpose

The Runner:

  1. Fetches batches of actions from the source store
  2. Migrates each action to the destination store
  3. Migrates associated logs
  4. Deletes migrated actions from the source
  5. Tracks progress and completion

Constructor

php
public function __construct( Config $config )

Requires a configured Config object with source/destination stores and loggers.

Methods

run()

php
public function run( int $batch_size = 250 ): int

Migrates a batch of actions.

Parameters:

  • $batch_size — Number of actions to migrate in this batch

Returns: Number of actions processed

Process:

  1. Query source store for oldest actions (up to batch_size)
  2. For each action:
    • Create action in destination store
    • Migrate all logs for that action
    • Delete action from source store
  3. Update progress bar if configured
  4. Return count of processed actions

migrate_action()

php
protected function migrate_action( int $action_id ): void

Migrates a single action by ID.

get_batch_fetcher()

php
protected function get_batch_fetcher(): BatchFetcher

Returns the BatchFetcher instance for querying source actions.

Batch Processing

Actions are processed in batches to avoid memory exhaustion and timeouts:

php
// Default batch size
$batch_size = 250;

// Filter to customize
$batch_size = apply_filters( 'action_scheduler/migration_batch_size', $batch_size );

Dry Run Mode

When Config::get_dry_run() returns true:

  • Create action in destination store
  • Migrate all logs for that action
  • Delete action from source store

Error Handling

If an action fails to migrate:

  • Create action in destination store
  • Migrate all logs for that action
  • Delete action from source store

Memory Management

The Runner is designed for batch processing:

  • DryRun_ActionMigrator is used instead of ActionMigrator
  • DryRun_LogMigrator is used instead of LogMigrator
  • No actual writes occur to the destination store
  • Source actions are NOT deleted
ClassPurpose
BatchFetcherQueries source store for actions to migrate
ActionMigratorMigrates a single action
LogMigratorMigrates logs for an action
DryRun_ActionMigratorSimulates action migration
DryRun_LogMigratorSimulates log migration