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
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 ): intMigrates 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()
php
protected function migrate_action( int $action_id ): voidMigrates a single action by ID.
get_batch_fetcher()
php
protected function get_batch_fetcher(): BatchFetcherReturns 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_ActionMigratoris used instead ofActionMigratorDryRun_LogMigratoris used instead ofLogMigrator- No actual writes occur to the destination store
- Source actions are NOT deleted
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 |