PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / trunk
Image Optimizer – Compress Images and Convert to WebP or AVIF vtrunk
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
← All changes | vendor/woocommerce/action-scheduler/classes/migration/ActionMigrator.php +25 -10 1.5.3 → trunk View file →
@@ -12,15 +12,27 @@
12 12 *
13 13 * @codeCoverageIgnore
14 14 */
15 15 class ActionMigrator {
16 - /** @var ActionScheduler_Store */
16 + /**
17 + * Source store instance.
18 + *
19 + * @var ActionScheduler_Store
20 + */
17 21 private $source;
18 22
19 - /** @var ActionScheduler_Store */
23 + /**
24 + * Destination store instance.
25 + *
26 + * @var ActionScheduler_Store
27 + */
20 28 private $destination;
21 29
22 - /** @var LogMigrator */
30 + /**
31 + * LogMigrator instance.
32 + *
33 + * @var LogMigrator
34 + */
23 35 private $log_migrator;
24 36
25 37 /**
26 38 * ActionMigrator constructor.
@@ -57,12 +69,12 @@
57 69 // null schedule means it's missing vital data.
58 70 // delete it and move on.
59 71 try {
60 72 $this->source->delete_action( $source_action_id );
61 - } catch ( \Exception $e ) {
73 + } catch ( \Exception $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
62 74 // nothing to do, it didn't exist in the first place.
63 75 }
64 - do_action( 'action_scheduler/no_action_to_migrate', $source_action_id, $this->source, $this->destination );
76 + do_action( 'action_scheduler/no_action_to_migrate', $source_action_id, $this->source, $this->destination ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
65 77
66 78 return 0;
67 79 }
68 80
@@ -68,13 +80,13 @@
68 80
69 81 try {
70 82
71 83 // Make sure the last attempt date is set correctly for completed and failed actions.
72 - $last_attempt_date = ( $status !== \ActionScheduler_Store::STATUS_PENDING ) ? $this->source->get_date( $source_action_id ) : null;
84 + $last_attempt_date = ( \ActionScheduler_Store::STATUS_PENDING !== $status ) ? $this->source->get_date( $source_action_id ) : null;
73 85
74 86 $destination_action_id = $this->destination->save_action( $action, null, $last_attempt_date );
75 87 } catch ( \Exception $e ) {
76 - do_action( 'action_scheduler/migrate_action_failed', $source_action_id, $this->source, $this->destination );
88 + do_action( 'action_scheduler/migrate_action_failed', $source_action_id, $this->source, $this->destination ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
77 89
78 90 return 0; // could not save the action in the new store.
79 91 }
80 92
@@ -79,12 +91,12 @@
79 91 }
80 92
81 93 try {
82 94 switch ( $status ) {
83 - case \ActionScheduler_Store::STATUS_FAILED :
95 + case \ActionScheduler_Store::STATUS_FAILED:
84 96 $this->destination->mark_failure( $destination_action_id );
85 97 break;
86 - case \ActionScheduler_Store::STATUS_CANCELED :
98 + case \ActionScheduler_Store::STATUS_CANCELED:
87 99 $this->destination->cancel_action( $destination_action_id );
88 100 break;
89 101 }
90 102
@@ -95,16 +107,19 @@
95 107 if ( ! is_a( $test_action, 'ActionScheduler_NullAction' ) ) {
96 108 // translators: %s is an action ID.
97 109 throw new \RuntimeException( sprintf( __( 'Unable to remove source migrated action %s', 'action-scheduler' ), $source_action_id ) );
98 110 }
99 - do_action( 'action_scheduler/migrated_action', $source_action_id, $destination_action_id, $this->source, $this->destination );
111 + do_action( 'action_scheduler/migrated_action', $source_action_id, $destination_action_id, $this->source, $this->destination ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
100 112
101 113 return $destination_action_id;
102 114 } catch ( \Exception $e ) {
103 115 // could not delete from the old store.
104 116 $this->source->mark_migrated( $source_action_id );
117 +
118 + // phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores
105 119 do_action( 'action_scheduler/migrate_action_incomplete', $source_action_id, $destination_action_id, $this->source, $this->destination );
106 120 do_action( 'action_scheduler/migrated_action', $source_action_id, $destination_action_id, $this->source, $this->destination );
121 + // phpcs:enable
107 122
108 123 return $destination_action_id;
109 124 }
110 125 }