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:
- Fetches batches of actions from the source store
- Migrates each action to the destination store
- Migrates associated logs
- Deletes migrated actions from the source
- Tracks progress and completion
Constructor
public function __construct( Config $config )
Requires a configured Config object with source/destination stores and loggers.
Methods
run()
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:
- Query source store for oldest actions (up to batch_size)
- For each action:
- Create action in destination store
- Migrate all logs for that action
- Delete action from source store
- Update progress bar if configured
- Return count of processed actions
migrate_action()
protected function migrate_action( int $action_id ): void
Migrates a single action by ID.
get_batch_fetcher()
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:
// 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:
DryRun_ActionMigratoris used instead ofActionMigratorDryRun_LogMigratoris used instead ofLogMigrator- No actual writes occur to the destination store
- Source actions are NOT deleted
Error Handling
If an action fails to migrate:
- The error is logged
- Processing continues with the next action
- Failed actions remain in the source store for retry
Memory Management
The Runner is designed for batch processing:
- Each batch is a separate request (via scheduled action)
- Progress is persistent via the Scheduler
- WP-CLI runs can process multiple batches with progress feedback
Related Classes
| Class | Purpose |
|---|---|
BatchFetcher |
Queries source store for actions to migrate |
ActionMigrator |
Migrates a single action |
LogMigrator |
Migrates logs for an action |
DryRun_ActionMigrator |
Simulates action migration |
DryRun_LogMigrator |
Simulates log migration |