PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 3.11.0
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v3.11.0
4.9.0 0.9.6 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.2 1.7.0 1.7.1 1.8.0 1.8.1 1.9.0 2.0.0 2.0.1 2.1.1 2.2.1 2.3.1 2.4.0 2.5.0 2.5.1 2.6.0 2.7.0 2.8.0 2.9.0 3.0.1 3.0.2 3.0.3 3.1.0 3.10.0 3.11.0 3.11.1 3.2.0 3.2.1 3.3.0 3.4.0 3.5.0 3.5.1 3.5.2 3.6.1 3.7.0 3.8.0 3.8.2 3.9.0 4.0.1 4.1.0 4.1.1 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.8.0 trunk 0.10.0 0.10.1 0.11.1 0.11.2 0.3.1 0.3.2 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.5.2 0.6 0.7 0.8 0.8.2 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5
wp-mail-smtp / vendor / woocommerce / action-scheduler / classes / migration / Runner.php
wp-mail-smtp / vendor / woocommerce / action-scheduler / classes / migration Last commit date
ActionMigrator.php 2 years ago ActionScheduler_DBStoreMigrator.php 2 years ago BatchFetcher.php 2 years ago Config.php 2 years ago Controller.php 2 years ago DryRun_ActionMigrator.php 2 years ago DryRun_LogMigrator.php 2 years ago LogMigrator.php 2 years ago Runner.php 2 years ago Scheduler.php 2 years ago
Runner.php
137 lines
1 <?php
2
3
4 namespace Action_Scheduler\Migration;
5
6 /**
7 * Class Runner
8 *
9 * @package Action_Scheduler\Migration
10 *
11 * @since 3.0.0
12 *
13 * @codeCoverageIgnore
14 */
15 class Runner {
16 /** @var ActionScheduler_Store */
17 private $source_store;
18
19 /** @var ActionScheduler_Store */
20 private $destination_store;
21
22 /** @var ActionScheduler_Logger */
23 private $source_logger;
24
25 /** @var ActionScheduler_Logger */
26 private $destination_logger;
27
28 /** @var BatchFetcher */
29 private $batch_fetcher;
30
31 /** @var ActionMigrator */
32 private $action_migrator;
33
34 /** @var LogMigrator */
35 private $log_migrator;
36
37 /** @var ProgressBar */
38 private $progress_bar;
39
40 /**
41 * Runner constructor.
42 *
43 * @param Config $config Migration configuration object.
44 */
45 public function __construct( Config $config ) {
46 $this->source_store = $config->get_source_store();
47 $this->destination_store = $config->get_destination_store();
48 $this->source_logger = $config->get_source_logger();
49 $this->destination_logger = $config->get_destination_logger();
50
51 $this->batch_fetcher = new BatchFetcher( $this->source_store );
52 if ( $config->get_dry_run() ) {
53 $this->log_migrator = new DryRun_LogMigrator( $this->source_logger, $this->destination_logger );
54 $this->action_migrator = new DryRun_ActionMigrator( $this->source_store, $this->destination_store, $this->log_migrator );
55 } else {
56 $this->log_migrator = new LogMigrator( $this->source_logger, $this->destination_logger );
57 $this->action_migrator = new ActionMigrator( $this->source_store, $this->destination_store, $this->log_migrator );
58 }
59
60 if ( defined( 'WP_CLI' ) && WP_CLI ) {
61 $this->progress_bar = $config->get_progress_bar();
62 }
63 }
64
65 /**
66 * Run migration batch.
67 *
68 * @param int $batch_size Optional batch size. Default 10.
69 *
70 * @return int Size of batch processed.
71 */
72 public function run( $batch_size = 10 ) {
73 $batch = $this->batch_fetcher->fetch( $batch_size );
74 $batch_size = count( $batch );
75
76 if ( ! $batch_size ) {
77 return 0;
78 }
79
80 if ( $this->progress_bar ) {
81 /* translators: %d: amount of actions */
82 $this->progress_bar->set_message( sprintf( _n( 'Migrating %d action', 'Migrating %d actions', $batch_size, 'action-scheduler' ), $batch_size ) );
83 $this->progress_bar->set_count( $batch_size );
84 }
85
86 $this->migrate_actions( $batch );
87
88 return $batch_size;
89 }
90
91 /**
92 * Migration a batch of actions.
93 *
94 * @param array $action_ids List of action IDs to migrate.
95 */
96 public function migrate_actions( array $action_ids ) {
97 do_action( 'action_scheduler/migration_batch_starting', $action_ids );
98
99 \ActionScheduler::logger()->unhook_stored_action();
100 $this->destination_logger->unhook_stored_action();
101
102 foreach ( $action_ids as $source_action_id ) {
103 $destination_action_id = $this->action_migrator->migrate( $source_action_id );
104 if ( $destination_action_id ) {
105 $this->destination_logger->log( $destination_action_id, sprintf(
106 /* translators: 1: source action ID 2: source store class 3: destination action ID 4: destination store class */
107 __( 'Migrated action with ID %1$d in %2$s to ID %3$d in %4$s', 'action-scheduler' ),
108 $source_action_id,
109 get_class( $this->source_store ),
110 $destination_action_id,
111 get_class( $this->destination_store )
112 ) );
113 }
114
115 if ( $this->progress_bar ) {
116 $this->progress_bar->tick();
117 }
118 }
119
120 if ( $this->progress_bar ) {
121 $this->progress_bar->finish();
122 }
123
124 \ActionScheduler::logger()->hook_stored_action();
125
126 do_action( 'action_scheduler/migration_batch_complete', $action_ids );
127 }
128
129 /**
130 * Initialize destination store and logger.
131 */
132 public function init_destination() {
133 $this->destination_store->init();
134 $this->destination_logger->init();
135 }
136 }
137