@@ -5,41 +5,41 @@ |
||
| 5 | 5 | * @package test_cases\lock |
| 6 | 6 | */ |
| 7 | 7 | class ActionScheduler_OptionLock_Test extends ActionScheduler_UnitTestCase { |
| 8 | - public function test_instance() { |
|
| 9 | - $lock = ActionScheduler::lock(); |
|
| 10 | - $this->assertInstanceOf( 'ActionScheduler_Lock', $lock ); |
|
| 11 | - $this->assertInstanceOf( 'ActionScheduler_OptionLock', $lock ); |
|
| 12 | - } |
|
| 8 | + public function test_instance() { |
|
| 9 | + $lock = ActionScheduler::lock(); |
|
| 10 | + $this->assertInstanceOf( 'ActionScheduler_Lock', $lock ); |
|
| 11 | + $this->assertInstanceOf( 'ActionScheduler_OptionLock', $lock ); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - public function test_is_locked() { |
|
| 15 | - $lock = ActionScheduler::lock(); |
|
| 16 | - $lock_type = md5( rand() ); |
|
| 14 | + public function test_is_locked() { |
|
| 15 | + $lock = ActionScheduler::lock(); |
|
| 16 | + $lock_type = md5( rand() ); |
|
| 17 | 17 | |
| 18 | - $this->assertFalse( $lock->is_locked( $lock_type ) ); |
|
| 18 | + $this->assertFalse( $lock->is_locked( $lock_type ) ); |
|
| 19 | 19 | |
| 20 | - $lock->set( $lock_type ); |
|
| 21 | - $this->assertTrue( $lock->is_locked( $lock_type ) ); |
|
| 22 | - } |
|
| 20 | + $lock->set( $lock_type ); |
|
| 21 | + $this->assertTrue( $lock->is_locked( $lock_type ) ); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function test_set() { |
|
| 25 | - $lock = ActionScheduler::lock(); |
|
| 26 | - $lock_type = md5( rand() ); |
|
| 24 | + public function test_set() { |
|
| 25 | + $lock = ActionScheduler::lock(); |
|
| 26 | + $lock_type = md5( rand() ); |
|
| 27 | 27 | |
| 28 | - $lock->set( $lock_type ); |
|
| 29 | - $this->assertTrue( $lock->is_locked( $lock_type ) ); |
|
| 30 | - } |
|
| 28 | + $lock->set( $lock_type ); |
|
| 29 | + $this->assertTrue( $lock->is_locked( $lock_type ) ); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function test_get_expiration() { |
|
| 33 | - $lock = ActionScheduler::lock(); |
|
| 34 | - $lock_type = md5( rand() ); |
|
| 32 | + public function test_get_expiration() { |
|
| 33 | + $lock = ActionScheduler::lock(); |
|
| 34 | + $lock_type = md5( rand() ); |
|
| 35 | 35 | |
| 36 | - $lock->set( $lock_type ); |
|
| 36 | + $lock->set( $lock_type ); |
|
| 37 | 37 | |
| 38 | - $expiration = $lock->get_expiration( $lock_type ); |
|
| 39 | - $current_time = time(); |
|
| 38 | + $expiration = $lock->get_expiration( $lock_type ); |
|
| 39 | + $current_time = time(); |
|
| 40 | 40 | |
| 41 | - $this->assertGreaterThanOrEqual( 0, $expiration ); |
|
| 42 | - $this->assertGreaterThan( $current_time, $expiration ); |
|
| 43 | - $this->assertLessThan( $current_time + MINUTE_IN_SECONDS + 1, $expiration ); |
|
| 44 | - } |
|
| 41 | + $this->assertGreaterThanOrEqual( 0, $expiration ); |
|
| 42 | + $this->assertGreaterThan( $current_time, $expiration ); |
|
| 43 | + $this->assertLessThan( $current_time + MINUTE_IN_SECONDS + 1, $expiration ); |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -7,39 +7,39 @@ |
||
| 7 | 7 | class ActionScheduler_OptionLock_Test extends ActionScheduler_UnitTestCase { |
| 8 | 8 | public function test_instance() { |
| 9 | 9 | $lock = ActionScheduler::lock(); |
| 10 | - $this->assertInstanceOf( 'ActionScheduler_Lock', $lock ); |
|
| 11 | - $this->assertInstanceOf( 'ActionScheduler_OptionLock', $lock ); |
|
| 10 | + $this->assertInstanceOf('ActionScheduler_Lock', $lock); |
|
| 11 | + $this->assertInstanceOf('ActionScheduler_OptionLock', $lock); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | public function test_is_locked() { |
| 15 | 15 | $lock = ActionScheduler::lock(); |
| 16 | - $lock_type = md5( rand() ); |
|
| 16 | + $lock_type = md5(rand()); |
|
| 17 | 17 | |
| 18 | - $this->assertFalse( $lock->is_locked( $lock_type ) ); |
|
| 18 | + $this->assertFalse($lock->is_locked($lock_type)); |
|
| 19 | 19 | |
| 20 | - $lock->set( $lock_type ); |
|
| 21 | - $this->assertTrue( $lock->is_locked( $lock_type ) ); |
|
| 20 | + $lock->set($lock_type); |
|
| 21 | + $this->assertTrue($lock->is_locked($lock_type)); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function test_set() { |
| 25 | 25 | $lock = ActionScheduler::lock(); |
| 26 | - $lock_type = md5( rand() ); |
|
| 26 | + $lock_type = md5(rand()); |
|
| 27 | 27 | |
| 28 | - $lock->set( $lock_type ); |
|
| 29 | - $this->assertTrue( $lock->is_locked( $lock_type ) ); |
|
| 28 | + $lock->set($lock_type); |
|
| 29 | + $this->assertTrue($lock->is_locked($lock_type)); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function test_get_expiration() { |
| 33 | 33 | $lock = ActionScheduler::lock(); |
| 34 | - $lock_type = md5( rand() ); |
|
| 34 | + $lock_type = md5(rand()); |
|
| 35 | 35 | |
| 36 | - $lock->set( $lock_type ); |
|
| 36 | + $lock->set($lock_type); |
|
| 37 | 37 | |
| 38 | - $expiration = $lock->get_expiration( $lock_type ); |
|
| 38 | + $expiration = $lock->get_expiration($lock_type); |
|
| 39 | 39 | $current_time = time(); |
| 40 | 40 | |
| 41 | - $this->assertGreaterThanOrEqual( 0, $expiration ); |
|
| 42 | - $this->assertGreaterThan( $current_time, $expiration ); |
|
| 43 | - $this->assertLessThan( $current_time + MINUTE_IN_SECONDS + 1, $expiration ); |
|
| 41 | + $this->assertGreaterThanOrEqual(0, $expiration); |
|
| 42 | + $this->assertGreaterThan($current_time, $expiration); |
|
| 43 | + $this->assertLessThan($current_time + MINUTE_IN_SECONDS + 1, $expiration); |
|
| 44 | 44 | } |
| 45 | 45 | } |
@@ -15,62 +15,62 @@ |
||
| 15 | 15 | * @group migration |
| 16 | 16 | */ |
| 17 | 17 | class Controller_Test extends ActionScheduler_UnitTestCase { |
| 18 | - /** |
|
| 19 | - * Test to ensure the Migration Controller will schedule the migration. |
|
| 20 | - */ |
|
| 21 | - public function test_schedules_migration() { |
|
| 22 | - as_unschedule_action( Scheduler::HOOK ); |
|
| 23 | - Controller::instance()->schedule_migration(); |
|
| 18 | + /** |
|
| 19 | + * Test to ensure the Migration Controller will schedule the migration. |
|
| 20 | + */ |
|
| 21 | + public function test_schedules_migration() { |
|
| 22 | + as_unschedule_action( Scheduler::HOOK ); |
|
| 23 | + Controller::instance()->schedule_migration(); |
|
| 24 | 24 | |
| 25 | - $this->assertTrue( |
|
| 26 | - as_next_scheduled_action( Scheduler::HOOK ) > 0, |
|
| 27 | - 'Confirm that the Migration Controller scheduled the migration.' |
|
| 28 | - ); |
|
| 25 | + $this->assertTrue( |
|
| 26 | + as_next_scheduled_action( Scheduler::HOOK ) > 0, |
|
| 27 | + 'Confirm that the Migration Controller scheduled the migration.' |
|
| 28 | + ); |
|
| 29 | 29 | |
| 30 | - as_unschedule_action( Scheduler::HOOK ); |
|
| 31 | - } |
|
| 30 | + as_unschedule_action( Scheduler::HOOK ); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Test to ensure that if an essential table is missing, the Migration |
|
| 35 | - * Controller will not schedule a migration. |
|
| 36 | - * |
|
| 37 | - * @see https://github.com/woocommerce/action-scheduler/issues/653 |
|
| 38 | - */ |
|
| 39 | - public function test_migration_not_scheduled_if_tables_are_missing() { |
|
| 40 | - as_unschedule_action( Scheduler::HOOK ); |
|
| 41 | - $this->rename_claims_table(); |
|
| 42 | - Controller::instance()->schedule_migration(); |
|
| 33 | + /** |
|
| 34 | + * Test to ensure that if an essential table is missing, the Migration |
|
| 35 | + * Controller will not schedule a migration. |
|
| 36 | + * |
|
| 37 | + * @see https://github.com/woocommerce/action-scheduler/issues/653 |
|
| 38 | + */ |
|
| 39 | + public function test_migration_not_scheduled_if_tables_are_missing() { |
|
| 40 | + as_unschedule_action( Scheduler::HOOK ); |
|
| 41 | + $this->rename_claims_table(); |
|
| 42 | + Controller::instance()->schedule_migration(); |
|
| 43 | 43 | |
| 44 | - $this->assertFalse( |
|
| 45 | - as_next_scheduled_action( Scheduler::HOOK ), |
|
| 46 | - 'When required tables are missing, the migration will not be scheduled.' |
|
| 47 | - ); |
|
| 44 | + $this->assertFalse( |
|
| 45 | + as_next_scheduled_action( Scheduler::HOOK ), |
|
| 46 | + 'When required tables are missing, the migration will not be scheduled.' |
|
| 47 | + ); |
|
| 48 | 48 | |
| 49 | - $this->restore_claims_table_name(); |
|
| 50 | - } |
|
| 49 | + $this->restore_claims_table_name(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Rename the claims table, so that it cannot be used by the library. |
|
| 54 | - */ |
|
| 55 | - private function rename_claims_table() { |
|
| 56 | - global $wpdb; |
|
| 57 | - $normal_table_name = $wpdb->prefix . Schema::CLAIMS_TABLE; |
|
| 58 | - $modified_table_name = $normal_table_name . 'x'; |
|
| 52 | + /** |
|
| 53 | + * Rename the claims table, so that it cannot be used by the library. |
|
| 54 | + */ |
|
| 55 | + private function rename_claims_table() { |
|
| 56 | + global $wpdb; |
|
| 57 | + $normal_table_name = $wpdb->prefix . Schema::CLAIMS_TABLE; |
|
| 58 | + $modified_table_name = $normal_table_name . 'x'; |
|
| 59 | 59 | |
| 60 | - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
| 61 | - $wpdb->query( "RENAME TABLE {$normal_table_name} TO {$modified_table_name}" ); |
|
| 62 | - } |
|
| 60 | + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
| 61 | + $wpdb->query( "RENAME TABLE {$normal_table_name} TO {$modified_table_name}" ); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Restore the expected name of the claims table, so that it can be used by the library |
|
| 66 | - * and any further tests. |
|
| 67 | - */ |
|
| 68 | - private function restore_claims_table_name() { |
|
| 69 | - global $wpdb; |
|
| 70 | - $normal_table_name = $wpdb->prefix . Schema::CLAIMS_TABLE; |
|
| 71 | - $modified_table_name = $normal_table_name . 'x'; |
|
| 64 | + /** |
|
| 65 | + * Restore the expected name of the claims table, so that it can be used by the library |
|
| 66 | + * and any further tests. |
|
| 67 | + */ |
|
| 68 | + private function restore_claims_table_name() { |
|
| 69 | + global $wpdb; |
|
| 70 | + $normal_table_name = $wpdb->prefix . Schema::CLAIMS_TABLE; |
|
| 71 | + $modified_table_name = $normal_table_name . 'x'; |
|
| 72 | 72 | |
| 73 | - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
| 74 | - $wpdb->query( "RENAME TABLE {$modified_table_name} TO {$normal_table_name}" ); |
|
| 75 | - } |
|
| 73 | + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
| 74 | + $wpdb->query( "RENAME TABLE {$modified_table_name} TO {$normal_table_name}" ); |
|
| 75 | + } |
|
| 76 | 76 | } |
@@ -19,15 +19,15 @@ discard block |
||
| 19 | 19 | * Test to ensure the Migration Controller will schedule the migration. |
| 20 | 20 | */ |
| 21 | 21 | public function test_schedules_migration() { |
| 22 | - as_unschedule_action( Scheduler::HOOK ); |
|
| 22 | + as_unschedule_action(Scheduler::HOOK); |
|
| 23 | 23 | Controller::instance()->schedule_migration(); |
| 24 | 24 | |
| 25 | 25 | $this->assertTrue( |
| 26 | - as_next_scheduled_action( Scheduler::HOOK ) > 0, |
|
| 26 | + as_next_scheduled_action(Scheduler::HOOK) > 0, |
|
| 27 | 27 | 'Confirm that the Migration Controller scheduled the migration.' |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - as_unschedule_action( Scheduler::HOOK ); |
|
| 30 | + as_unschedule_action(Scheduler::HOOK); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -37,12 +37,12 @@ discard block |
||
| 37 | 37 | * @see https://github.com/woocommerce/action-scheduler/issues/653 |
| 38 | 38 | */ |
| 39 | 39 | public function test_migration_not_scheduled_if_tables_are_missing() { |
| 40 | - as_unschedule_action( Scheduler::HOOK ); |
|
| 40 | + as_unschedule_action(Scheduler::HOOK); |
|
| 41 | 41 | $this->rename_claims_table(); |
| 42 | 42 | Controller::instance()->schedule_migration(); |
| 43 | 43 | |
| 44 | 44 | $this->assertFalse( |
| 45 | - as_next_scheduled_action( Scheduler::HOOK ), |
|
| 45 | + as_next_scheduled_action(Scheduler::HOOK), |
|
| 46 | 46 | 'When required tables are missing, the migration will not be scheduled.' |
| 47 | 47 | ); |
| 48 | 48 | |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | private function rename_claims_table() { |
| 56 | 56 | global $wpdb; |
| 57 | - $normal_table_name = $wpdb->prefix . Schema::CLAIMS_TABLE; |
|
| 58 | - $modified_table_name = $normal_table_name . 'x'; |
|
| 57 | + $normal_table_name = $wpdb->prefix.Schema::CLAIMS_TABLE; |
|
| 58 | + $modified_table_name = $normal_table_name.'x'; |
|
| 59 | 59 | |
| 60 | 60 | // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
| 61 | - $wpdb->query( "RENAME TABLE {$normal_table_name} TO {$modified_table_name}" ); |
|
| 61 | + $wpdb->query("RENAME TABLE {$normal_table_name} TO {$modified_table_name}"); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | private function restore_claims_table_name() { |
| 69 | 69 | global $wpdb; |
| 70 | - $normal_table_name = $wpdb->prefix . Schema::CLAIMS_TABLE; |
|
| 71 | - $modified_table_name = $normal_table_name . 'x'; |
|
| 70 | + $normal_table_name = $wpdb->prefix.Schema::CLAIMS_TABLE; |
|
| 71 | + $modified_table_name = $normal_table_name.'x'; |
|
| 72 | 72 | |
| 73 | 73 | // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
| 74 | - $wpdb->query( "RENAME TABLE {$modified_table_name} TO {$normal_table_name}" ); |
|
| 74 | + $wpdb->query("RENAME TABLE {$modified_table_name} TO {$normal_table_name}"); |
|
| 75 | 75 | } |
| 76 | 76 | } |
@@ -6,44 +6,44 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | abstract class ActionScheduler_Store_Deprecated { |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * Mark an action that failed to fetch correctly as failed. |
|
| 11 | - * |
|
| 12 | - * @since 2.2.6 |
|
| 13 | - * |
|
| 14 | - * @param int $action_id The ID of the action. |
|
| 15 | - */ |
|
| 16 | - public function mark_failed_fetch_action( $action_id ) { |
|
| 17 | - _deprecated_function( __METHOD__, '3.0.0', 'ActionScheduler_Store::mark_failure()' ); |
|
| 18 | - self::$store->mark_failure( $action_id ); |
|
| 19 | - } |
|
| 9 | + /** |
|
| 10 | + * Mark an action that failed to fetch correctly as failed. |
|
| 11 | + * |
|
| 12 | + * @since 2.2.6 |
|
| 13 | + * |
|
| 14 | + * @param int $action_id The ID of the action. |
|
| 15 | + */ |
|
| 16 | + public function mark_failed_fetch_action( $action_id ) { |
|
| 17 | + _deprecated_function( __METHOD__, '3.0.0', 'ActionScheduler_Store::mark_failure()' ); |
|
| 18 | + self::$store->mark_failure( $action_id ); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Add base hooks |
|
| 23 | - * |
|
| 24 | - * @since 2.2.6 |
|
| 25 | - */ |
|
| 26 | - protected static function hook() { |
|
| 27 | - _deprecated_function( __METHOD__, '3.0.0' ); |
|
| 28 | - } |
|
| 21 | + /** |
|
| 22 | + * Add base hooks |
|
| 23 | + * |
|
| 24 | + * @since 2.2.6 |
|
| 25 | + */ |
|
| 26 | + protected static function hook() { |
|
| 27 | + _deprecated_function( __METHOD__, '3.0.0' ); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Remove base hooks |
|
| 32 | - * |
|
| 33 | - * @since 2.2.6 |
|
| 34 | - */ |
|
| 35 | - protected static function unhook() { |
|
| 36 | - _deprecated_function( __METHOD__, '3.0.0' ); |
|
| 37 | - } |
|
| 30 | + /** |
|
| 31 | + * Remove base hooks |
|
| 32 | + * |
|
| 33 | + * @since 2.2.6 |
|
| 34 | + */ |
|
| 35 | + protected static function unhook() { |
|
| 36 | + _deprecated_function( __METHOD__, '3.0.0' ); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Get the site's local time. |
|
| 41 | - * |
|
| 42 | - * @deprecated 2.1.0 |
|
| 43 | - * @return DateTimeZone |
|
| 44 | - */ |
|
| 45 | - protected function get_local_timezone() { |
|
| 46 | - _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' ); |
|
| 47 | - return ActionScheduler_TimezoneHelper::get_local_timezone(); |
|
| 48 | - } |
|
| 39 | + /** |
|
| 40 | + * Get the site's local time. |
|
| 41 | + * |
|
| 42 | + * @deprecated 2.1.0 |
|
| 43 | + * @return DateTimeZone |
|
| 44 | + */ |
|
| 45 | + protected function get_local_timezone() { |
|
| 46 | + _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' ); |
|
| 47 | + return ActionScheduler_TimezoneHelper::get_local_timezone(); |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -13,9 +13,9 @@ discard block |
||
| 13 | 13 | * |
| 14 | 14 | * @param int $action_id The ID of the action. |
| 15 | 15 | */ |
| 16 | - public function mark_failed_fetch_action( $action_id ) { |
|
| 17 | - _deprecated_function( __METHOD__, '3.0.0', 'ActionScheduler_Store::mark_failure()' ); |
|
| 18 | - self::$store->mark_failure( $action_id ); |
|
| 16 | + public function mark_failed_fetch_action($action_id) { |
|
| 17 | + _deprecated_function(__METHOD__, '3.0.0', 'ActionScheduler_Store::mark_failure()'); |
|
| 18 | + self::$store->mark_failure($action_id); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @since 2.2.6 |
| 25 | 25 | */ |
| 26 | 26 | protected static function hook() { |
| 27 | - _deprecated_function( __METHOD__, '3.0.0' ); |
|
| 27 | + _deprecated_function(__METHOD__, '3.0.0'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @since 2.2.6 |
| 34 | 34 | */ |
| 35 | 35 | protected static function unhook() { |
| 36 | - _deprecated_function( __METHOD__, '3.0.0' ); |
|
| 36 | + _deprecated_function(__METHOD__, '3.0.0'); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @return DateTimeZone |
| 44 | 44 | */ |
| 45 | 45 | protected function get_local_timezone() { |
| 46 | - _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' ); |
|
| 46 | + _deprecated_function(__FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()'); |
|
| 47 | 47 | return ActionScheduler_TimezoneHelper::get_local_timezone(); |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | * Class ActionScheduler_NullLogEntry |
| 5 | 5 | */ |
| 6 | 6 | class ActionScheduler_NullLogEntry extends ActionScheduler_LogEntry { |
| 7 | - public function __construct( $action_id = '', $message = '' ) { |
|
| 7 | + public function __construct($action_id = '', $message = '') { |
|
| 8 | 8 | // nothing to see here |
| 9 | 9 | } |
| 10 | 10 | } |
@@ -4,8 +4,8 @@ |
||
| 4 | 4 | * Class ActionScheduler_NullLogEntry |
| 5 | 5 | */ |
| 6 | 6 | class ActionScheduler_NullLogEntry extends ActionScheduler_LogEntry { |
| 7 | - public function __construct( $action_id = '', $message = '' ) { |
|
| 8 | - // nothing to see here |
|
| 9 | - } |
|
| 7 | + public function __construct( $action_id = '', $message = '' ) { |
|
| 8 | + // nothing to see here |
|
| 9 | + } |
|
| 10 | 10 | } |
| 11 | 11 | |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | * |
| 11 | 11 | * @param null $date The date & time to run the action. |
| 12 | 12 | */ |
| 13 | - public function __construct( DateTime $date = null ) { |
|
| 13 | + public function __construct(DateTime $date = null) { |
|
| 14 | 14 | $this->scheduled_date = null; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -5,25 +5,25 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class ActionScheduler_NullSchedule extends ActionScheduler_SimpleSchedule { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * Make the $date param optional and default to null. |
|
| 10 | - * |
|
| 11 | - * @param null $date The date & time to run the action. |
|
| 12 | - */ |
|
| 13 | - public function __construct( DateTime $date = null ) { |
|
| 14 | - $this->scheduled_date = null; |
|
| 15 | - } |
|
| 8 | + /** |
|
| 9 | + * Make the $date param optional and default to null. |
|
| 10 | + * |
|
| 11 | + * @param null $date The date & time to run the action. |
|
| 12 | + */ |
|
| 13 | + public function __construct( DateTime $date = null ) { |
|
| 14 | + $this->scheduled_date = null; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * This schedule has no scheduled DateTime, so we need to override the parent __sleep() |
|
| 19 | - * |
|
| 20 | - * @return array |
|
| 21 | - */ |
|
| 22 | - public function __sleep() { |
|
| 23 | - return array(); |
|
| 24 | - } |
|
| 17 | + /** |
|
| 18 | + * This schedule has no scheduled DateTime, so we need to override the parent __sleep() |
|
| 19 | + * |
|
| 20 | + * @return array |
|
| 21 | + */ |
|
| 22 | + public function __sleep() { |
|
| 23 | + return array(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function __wakeup() { |
|
| 27 | - $this->scheduled_date = null; |
|
| 28 | - } |
|
| 26 | + public function __wakeup() { |
|
| 27 | + $this->scheduled_date = null; |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -9,41 +9,41 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class ActionScheduler_OptionLock extends ActionScheduler_Lock { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Set a lock using options for a given amount of time (60 seconds by default). |
|
| 14 | - * |
|
| 15 | - * Using an autoloaded option avoids running database queries or other resource intensive tasks |
|
| 16 | - * on frequently triggered hooks, like 'init' or 'shutdown'. |
|
| 17 | - * |
|
| 18 | - * For example, ActionScheduler_QueueRunner->maybe_dispatch_async_request() uses a lock to avoid |
|
| 19 | - * calling ActionScheduler_QueueRunner->has_maximum_concurrent_batches() every time the 'shutdown', |
|
| 20 | - * hook is triggered, because that method calls ActionScheduler_QueueRunner->store->get_claim_count() |
|
| 21 | - * to find the current number of claims in the database. |
|
| 22 | - * |
|
| 23 | - * @param string $lock_type A string to identify different lock types. |
|
| 24 | - * @bool True if lock value has changed, false if not or if set failed. |
|
| 25 | - */ |
|
| 26 | - public function set( $lock_type ) { |
|
| 27 | - return update_option( $this->get_key( $lock_type ), time() + $this->get_duration( $lock_type ) ); |
|
| 28 | - } |
|
| 12 | + /** |
|
| 13 | + * Set a lock using options for a given amount of time (60 seconds by default). |
|
| 14 | + * |
|
| 15 | + * Using an autoloaded option avoids running database queries or other resource intensive tasks |
|
| 16 | + * on frequently triggered hooks, like 'init' or 'shutdown'. |
|
| 17 | + * |
|
| 18 | + * For example, ActionScheduler_QueueRunner->maybe_dispatch_async_request() uses a lock to avoid |
|
| 19 | + * calling ActionScheduler_QueueRunner->has_maximum_concurrent_batches() every time the 'shutdown', |
|
| 20 | + * hook is triggered, because that method calls ActionScheduler_QueueRunner->store->get_claim_count() |
|
| 21 | + * to find the current number of claims in the database. |
|
| 22 | + * |
|
| 23 | + * @param string $lock_type A string to identify different lock types. |
|
| 24 | + * @bool True if lock value has changed, false if not or if set failed. |
|
| 25 | + */ |
|
| 26 | + public function set( $lock_type ) { |
|
| 27 | + return update_option( $this->get_key( $lock_type ), time() + $this->get_duration( $lock_type ) ); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * If a lock is set, return the timestamp it was set to expiry. |
|
| 32 | - * |
|
| 33 | - * @param string $lock_type A string to identify different lock types. |
|
| 34 | - * @return bool|int False if no lock is set, otherwise the timestamp for when the lock is set to expire. |
|
| 35 | - */ |
|
| 36 | - public function get_expiration( $lock_type ) { |
|
| 37 | - return get_option( $this->get_key( $lock_type ) ); |
|
| 38 | - } |
|
| 30 | + /** |
|
| 31 | + * If a lock is set, return the timestamp it was set to expiry. |
|
| 32 | + * |
|
| 33 | + * @param string $lock_type A string to identify different lock types. |
|
| 34 | + * @return bool|int False if no lock is set, otherwise the timestamp for when the lock is set to expire. |
|
| 35 | + */ |
|
| 36 | + public function get_expiration( $lock_type ) { |
|
| 37 | + return get_option( $this->get_key( $lock_type ) ); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Get the key to use for storing the lock in the transient |
|
| 42 | - * |
|
| 43 | - * @param string $lock_type A string to identify different lock types. |
|
| 44 | - * @return string |
|
| 45 | - */ |
|
| 46 | - protected function get_key( $lock_type ) { |
|
| 47 | - return sprintf( 'action_scheduler_lock_%s', $lock_type ); |
|
| 48 | - } |
|
| 40 | + /** |
|
| 41 | + * Get the key to use for storing the lock in the transient |
|
| 42 | + * |
|
| 43 | + * @param string $lock_type A string to identify different lock types. |
|
| 44 | + * @return string |
|
| 45 | + */ |
|
| 46 | + protected function get_key( $lock_type ) { |
|
| 47 | + return sprintf( 'action_scheduler_lock_%s', $lock_type ); |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | * @param string $lock_type A string to identify different lock types. |
| 24 | 24 | * @bool True if lock value has changed, false if not or if set failed. |
| 25 | 25 | */ |
| 26 | - public function set( $lock_type ) { |
|
| 27 | - return update_option( $this->get_key( $lock_type ), time() + $this->get_duration( $lock_type ) ); |
|
| 26 | + public function set($lock_type) { |
|
| 27 | + return update_option($this->get_key($lock_type), time() + $this->get_duration($lock_type)); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | * @param string $lock_type A string to identify different lock types. |
| 34 | 34 | * @return bool|int False if no lock is set, otherwise the timestamp for when the lock is set to expire. |
| 35 | 35 | */ |
| 36 | - public function get_expiration( $lock_type ) { |
|
| 37 | - return get_option( $this->get_key( $lock_type ) ); |
|
| 36 | + public function get_expiration($lock_type) { |
|
| 37 | + return get_option($this->get_key($lock_type)); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param string $lock_type A string to identify different lock types. |
| 44 | 44 | * @return string |
| 45 | 45 | */ |
| 46 | - protected function get_key( $lock_type ) { |
|
| 47 | - return sprintf( 'action_scheduler_lock_%s', $lock_type ); |
|
| 46 | + protected function get_key($lock_type) { |
|
| 47 | + return sprintf('action_scheduler_lock_%s', $lock_type); |
|
| 48 | 48 | } |
| 49 | 49 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * @param DateTime $date The date & time to run the action. |
| 24 | 24 | */ |
| 25 | - public function __construct( DateTime $date ) { |
|
| 25 | + public function __construct(DateTime $date) { |
|
| 26 | 26 | $this->scheduled_date = $date; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param DateTime $after |
| 40 | 40 | * @return DateTime |
| 41 | 41 | */ |
| 42 | - abstract protected function calculate_next( DateTime $after ); |
|
| 42 | + abstract protected function calculate_next(DateTime $after); |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Get the next date & time when this schedule should run after a given date & time. |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | * @param DateTime $after |
| 48 | 48 | * @return DateTime|null |
| 49 | 49 | */ |
| 50 | - public function get_next( DateTime $after ) { |
|
| 50 | + public function get_next(DateTime $after) { |
|
| 51 | 51 | $after = clone $after; |
| 52 | - if ( $after > $this->scheduled_date ) { |
|
| 53 | - $after = $this->calculate_next( $after ); |
|
| 52 | + if ($after > $this->scheduled_date) { |
|
| 53 | + $after = $this->calculate_next($after); |
|
| 54 | 54 | return $after; |
| 55 | 55 | } |
| 56 | 56 | return clone $this->scheduled_date; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public function __wakeup() { |
| 80 | - $this->scheduled_date = as_get_datetime_object( $this->scheduled_timestamp ); |
|
| 81 | - unset( $this->scheduled_timestamp ); |
|
| 80 | + $this->scheduled_date = as_get_datetime_object($this->scheduled_timestamp); |
|
| 81 | + unset($this->scheduled_timestamp); |
|
| 82 | 82 | } |
| 83 | 83 | } |
@@ -5,80 +5,80 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | abstract class ActionScheduler_Abstract_Schedule extends ActionScheduler_Schedule_Deprecated { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * The date & time the schedule is set to run. |
|
| 10 | - * |
|
| 11 | - * @var DateTime |
|
| 12 | - */ |
|
| 13 | - private $scheduled_date = null; |
|
| 8 | + /** |
|
| 9 | + * The date & time the schedule is set to run. |
|
| 10 | + * |
|
| 11 | + * @var DateTime |
|
| 12 | + */ |
|
| 13 | + private $scheduled_date = null; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Timestamp equivalent of @see $this->scheduled_date |
|
| 17 | - * |
|
| 18 | - * @var int |
|
| 19 | - */ |
|
| 20 | - protected $scheduled_timestamp = null; |
|
| 15 | + /** |
|
| 16 | + * Timestamp equivalent of @see $this->scheduled_date |
|
| 17 | + * |
|
| 18 | + * @var int |
|
| 19 | + */ |
|
| 20 | + protected $scheduled_timestamp = null; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @param DateTime $date The date & time to run the action. |
|
| 24 | - */ |
|
| 25 | - public function __construct( DateTime $date ) { |
|
| 26 | - $this->scheduled_date = $date; |
|
| 27 | - } |
|
| 22 | + /** |
|
| 23 | + * @param DateTime $date The date & time to run the action. |
|
| 24 | + */ |
|
| 25 | + public function __construct( DateTime $date ) { |
|
| 26 | + $this->scheduled_date = $date; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Check if a schedule should recur. |
|
| 31 | - * |
|
| 32 | - * @return bool |
|
| 33 | - */ |
|
| 34 | - abstract public function is_recurring(); |
|
| 29 | + /** |
|
| 30 | + * Check if a schedule should recur. |
|
| 31 | + * |
|
| 32 | + * @return bool |
|
| 33 | + */ |
|
| 34 | + abstract public function is_recurring(); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Calculate when the next instance of this schedule would run based on a given date & time. |
|
| 38 | - * |
|
| 39 | - * @param DateTime $after |
|
| 40 | - * @return DateTime |
|
| 41 | - */ |
|
| 42 | - abstract protected function calculate_next( DateTime $after ); |
|
| 36 | + /** |
|
| 37 | + * Calculate when the next instance of this schedule would run based on a given date & time. |
|
| 38 | + * |
|
| 39 | + * @param DateTime $after |
|
| 40 | + * @return DateTime |
|
| 41 | + */ |
|
| 42 | + abstract protected function calculate_next( DateTime $after ); |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Get the next date & time when this schedule should run after a given date & time. |
|
| 46 | - * |
|
| 47 | - * @param DateTime $after |
|
| 48 | - * @return DateTime|null |
|
| 49 | - */ |
|
| 50 | - public function get_next( DateTime $after ) { |
|
| 51 | - $after = clone $after; |
|
| 52 | - if ( $after > $this->scheduled_date ) { |
|
| 53 | - $after = $this->calculate_next( $after ); |
|
| 54 | - return $after; |
|
| 55 | - } |
|
| 56 | - return clone $this->scheduled_date; |
|
| 57 | - } |
|
| 44 | + /** |
|
| 45 | + * Get the next date & time when this schedule should run after a given date & time. |
|
| 46 | + * |
|
| 47 | + * @param DateTime $after |
|
| 48 | + * @return DateTime|null |
|
| 49 | + */ |
|
| 50 | + public function get_next( DateTime $after ) { |
|
| 51 | + $after = clone $after; |
|
| 52 | + if ( $after > $this->scheduled_date ) { |
|
| 53 | + $after = $this->calculate_next( $after ); |
|
| 54 | + return $after; |
|
| 55 | + } |
|
| 56 | + return clone $this->scheduled_date; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Get the date & time the schedule is set to run. |
|
| 61 | - * |
|
| 62 | - * @return DateTime|null |
|
| 63 | - */ |
|
| 64 | - public function get_date() { |
|
| 65 | - return $this->scheduled_date; |
|
| 66 | - } |
|
| 59 | + /** |
|
| 60 | + * Get the date & time the schedule is set to run. |
|
| 61 | + * |
|
| 62 | + * @return DateTime|null |
|
| 63 | + */ |
|
| 64 | + public function get_date() { |
|
| 65 | + return $this->scheduled_date; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * For PHP 5.2 compat, since DateTime objects can't be serialized |
|
| 70 | - * |
|
| 71 | - * @return array |
|
| 72 | - */ |
|
| 73 | - public function __sleep() { |
|
| 74 | - $this->scheduled_timestamp = $this->scheduled_date->getTimestamp(); |
|
| 75 | - return array( |
|
| 76 | - 'scheduled_timestamp', |
|
| 77 | - ); |
|
| 78 | - } |
|
| 68 | + /** |
|
| 69 | + * For PHP 5.2 compat, since DateTime objects can't be serialized |
|
| 70 | + * |
|
| 71 | + * @return array |
|
| 72 | + */ |
|
| 73 | + public function __sleep() { |
|
| 74 | + $this->scheduled_timestamp = $this->scheduled_date->getTimestamp(); |
|
| 75 | + return array( |
|
| 76 | + 'scheduled_timestamp', |
|
| 77 | + ); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - public function __wakeup() { |
|
| 81 | - $this->scheduled_date = as_get_datetime_object( $this->scheduled_timestamp ); |
|
| 82 | - unset( $this->scheduled_timestamp ); |
|
| 83 | - } |
|
| 80 | + public function __wakeup() { |
|
| 81 | + $this->scheduled_date = as_get_datetime_object( $this->scheduled_timestamp ); |
|
| 82 | + unset( $this->scheduled_timestamp ); |
|
| 83 | + } |
|
| 84 | 84 | } |
@@ -15,35 +15,35 @@ |
||
| 15 | 15 | * @codeCoverageIgnore |
| 16 | 16 | */ |
| 17 | 17 | class LogMigrator { |
| 18 | - /** @var ActionScheduler_Logger */ |
|
| 19 | - private $source; |
|
| 18 | + /** @var ActionScheduler_Logger */ |
|
| 19 | + private $source; |
|
| 20 | 20 | |
| 21 | - /** @var ActionScheduler_Logger */ |
|
| 22 | - private $destination; |
|
| 21 | + /** @var ActionScheduler_Logger */ |
|
| 22 | + private $destination; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * ActionMigrator constructor. |
|
| 26 | - * |
|
| 27 | - * @param ActionScheduler_Logger $source_logger Source logger object. |
|
| 28 | - * @param ActionScheduler_Logger $destination_Logger Destination logger object. |
|
| 29 | - */ |
|
| 30 | - public function __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_Logger ) { |
|
| 31 | - $this->source = $source_logger; |
|
| 32 | - $this->destination = $destination_Logger; |
|
| 33 | - } |
|
| 24 | + /** |
|
| 25 | + * ActionMigrator constructor. |
|
| 26 | + * |
|
| 27 | + * @param ActionScheduler_Logger $source_logger Source logger object. |
|
| 28 | + * @param ActionScheduler_Logger $destination_Logger Destination logger object. |
|
| 29 | + */ |
|
| 30 | + public function __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_Logger ) { |
|
| 31 | + $this->source = $source_logger; |
|
| 32 | + $this->destination = $destination_Logger; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Migrate an action log. |
|
| 37 | - * |
|
| 38 | - * @param int $source_action_id Source logger object. |
|
| 39 | - * @param int $destination_action_id Destination logger object. |
|
| 40 | - */ |
|
| 41 | - public function migrate( $source_action_id, $destination_action_id ) { |
|
| 42 | - $logs = $this->source->get_logs( $source_action_id ); |
|
| 43 | - foreach ( $logs as $log ) { |
|
| 44 | - if ( $log->get_action_id() == $source_action_id ) { |
|
| 45 | - $this->destination->log( $destination_action_id, $log->get_message(), $log->get_date() ); |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 35 | + /** |
|
| 36 | + * Migrate an action log. |
|
| 37 | + * |
|
| 38 | + * @param int $source_action_id Source logger object. |
|
| 39 | + * @param int $destination_action_id Destination logger object. |
|
| 40 | + */ |
|
| 41 | + public function migrate( $source_action_id, $destination_action_id ) { |
|
| 42 | + $logs = $this->source->get_logs( $source_action_id ); |
|
| 43 | + foreach ( $logs as $log ) { |
|
| 44 | + if ( $log->get_action_id() == $source_action_id ) { |
|
| 45 | + $this->destination->log( $destination_action_id, $log->get_message(), $log->get_date() ); |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @param ActionScheduler_Logger $source_logger Source logger object. |
| 28 | 28 | * @param ActionScheduler_Logger $destination_Logger Destination logger object. |
| 29 | 29 | */ |
| 30 | - public function __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_Logger ) { |
|
| 30 | + public function __construct(ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_Logger) { |
|
| 31 | 31 | $this->source = $source_logger; |
| 32 | 32 | $this->destination = $destination_Logger; |
| 33 | 33 | } |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | * @param int $source_action_id Source logger object. |
| 39 | 39 | * @param int $destination_action_id Destination logger object. |
| 40 | 40 | */ |
| 41 | - public function migrate( $source_action_id, $destination_action_id ) { |
|
| 42 | - $logs = $this->source->get_logs( $source_action_id ); |
|
| 43 | - foreach ( $logs as $log ) { |
|
| 44 | - if ( $log->get_action_id() == $source_action_id ) { |
|
| 45 | - $this->destination->log( $destination_action_id, $log->get_message(), $log->get_date() ); |
|
| 41 | + public function migrate($source_action_id, $destination_action_id) { |
|
| 42 | + $logs = $this->source->get_logs($source_action_id); |
|
| 43 | + foreach ($logs as $log) { |
|
| 44 | + if ($log->get_action_id() == $source_action_id) { |
|
| 45 | + $this->destination->log($destination_action_id, $log->get_message(), $log->get_date()); |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -17,152 +17,152 @@ |
||
| 17 | 17 | * A config builder for the ActionScheduler\Migration\Runner class |
| 18 | 18 | */ |
| 19 | 19 | class Config { |
| 20 | - /** @var ActionScheduler_Store */ |
|
| 21 | - private $source_store; |
|
| 22 | - |
|
| 23 | - /** @var ActionScheduler_Logger */ |
|
| 24 | - private $source_logger; |
|
| 25 | - |
|
| 26 | - /** @var ActionScheduler_Store */ |
|
| 27 | - private $destination_store; |
|
| 28 | - |
|
| 29 | - /** @var ActionScheduler_Logger */ |
|
| 30 | - private $destination_logger; |
|
| 31 | - |
|
| 32 | - /** @var Progress bar */ |
|
| 33 | - private $progress_bar; |
|
| 34 | - |
|
| 35 | - /** @var bool */ |
|
| 36 | - private $dry_run = false; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Config constructor. |
|
| 40 | - */ |
|
| 41 | - public function __construct() { |
|
| 42 | - |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Get the configured source store. |
|
| 47 | - * |
|
| 48 | - * @return ActionScheduler_Store |
|
| 49 | - */ |
|
| 50 | - public function get_source_store() { |
|
| 51 | - if ( empty( $this->source_store ) ) { |
|
| 52 | - throw new \RuntimeException( __( 'Source store must be configured before running a migration', 'action-scheduler' ) ); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - return $this->source_store; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Set the configured source store. |
|
| 60 | - * |
|
| 61 | - * @param ActionScheduler_Store $store Source store object. |
|
| 62 | - */ |
|
| 63 | - public function set_source_store( Store $store ) { |
|
| 64 | - $this->source_store = $store; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Get the configured source loger. |
|
| 69 | - * |
|
| 70 | - * @return ActionScheduler_Logger |
|
| 71 | - */ |
|
| 72 | - public function get_source_logger() { |
|
| 73 | - if ( empty( $this->source_logger ) ) { |
|
| 74 | - throw new \RuntimeException( __( 'Source logger must be configured before running a migration', 'action-scheduler' ) ); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - return $this->source_logger; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Set the configured source logger. |
|
| 82 | - * |
|
| 83 | - * @param ActionScheduler_Logger $logger |
|
| 84 | - */ |
|
| 85 | - public function set_source_logger( Logger $logger ) { |
|
| 86 | - $this->source_logger = $logger; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Get the configured destination store. |
|
| 91 | - * |
|
| 92 | - * @return ActionScheduler_Store |
|
| 93 | - */ |
|
| 94 | - public function get_destination_store() { |
|
| 95 | - if ( empty( $this->destination_store ) ) { |
|
| 96 | - throw new \RuntimeException( __( 'Destination store must be configured before running a migration', 'action-scheduler' ) ); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - return $this->destination_store; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Set the configured destination store. |
|
| 104 | - * |
|
| 105 | - * @param ActionScheduler_Store $store |
|
| 106 | - */ |
|
| 107 | - public function set_destination_store( Store $store ) { |
|
| 108 | - $this->destination_store = $store; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Get the configured destination logger. |
|
| 113 | - * |
|
| 114 | - * @return ActionScheduler_Logger |
|
| 115 | - */ |
|
| 116 | - public function get_destination_logger() { |
|
| 117 | - if ( empty( $this->destination_logger ) ) { |
|
| 118 | - throw new \RuntimeException( __( 'Destination logger must be configured before running a migration', 'action-scheduler' ) ); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - return $this->destination_logger; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Set the configured destination logger. |
|
| 126 | - * |
|
| 127 | - * @param ActionScheduler_Logger $logger |
|
| 128 | - */ |
|
| 129 | - public function set_destination_logger( Logger $logger ) { |
|
| 130 | - $this->destination_logger = $logger; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Get flag indicating whether it's a dry run. |
|
| 135 | - * |
|
| 136 | - * @return bool |
|
| 137 | - */ |
|
| 138 | - public function get_dry_run() { |
|
| 139 | - return $this->dry_run; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Set flag indicating whether it's a dry run. |
|
| 144 | - * |
|
| 145 | - * @param bool $dry_run |
|
| 146 | - */ |
|
| 147 | - public function set_dry_run( $dry_run ) { |
|
| 148 | - $this->dry_run = (bool) $dry_run; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Get progress bar object. |
|
| 153 | - * |
|
| 154 | - * @return ActionScheduler\WPCLI\ProgressBar |
|
| 155 | - */ |
|
| 156 | - public function get_progress_bar() { |
|
| 157 | - return $this->progress_bar; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * Set progress bar object. |
|
| 162 | - * |
|
| 163 | - * @param ActionScheduler\WPCLI\ProgressBar $progress_bar |
|
| 164 | - */ |
|
| 165 | - public function set_progress_bar( ProgressBar $progress_bar ) { |
|
| 166 | - $this->progress_bar = $progress_bar; |
|
| 167 | - } |
|
| 20 | + /** @var ActionScheduler_Store */ |
|
| 21 | + private $source_store; |
|
| 22 | + |
|
| 23 | + /** @var ActionScheduler_Logger */ |
|
| 24 | + private $source_logger; |
|
| 25 | + |
|
| 26 | + /** @var ActionScheduler_Store */ |
|
| 27 | + private $destination_store; |
|
| 28 | + |
|
| 29 | + /** @var ActionScheduler_Logger */ |
|
| 30 | + private $destination_logger; |
|
| 31 | + |
|
| 32 | + /** @var Progress bar */ |
|
| 33 | + private $progress_bar; |
|
| 34 | + |
|
| 35 | + /** @var bool */ |
|
| 36 | + private $dry_run = false; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Config constructor. |
|
| 40 | + */ |
|
| 41 | + public function __construct() { |
|
| 42 | + |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Get the configured source store. |
|
| 47 | + * |
|
| 48 | + * @return ActionScheduler_Store |
|
| 49 | + */ |
|
| 50 | + public function get_source_store() { |
|
| 51 | + if ( empty( $this->source_store ) ) { |
|
| 52 | + throw new \RuntimeException( __( 'Source store must be configured before running a migration', 'action-scheduler' ) ); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + return $this->source_store; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Set the configured source store. |
|
| 60 | + * |
|
| 61 | + * @param ActionScheduler_Store $store Source store object. |
|
| 62 | + */ |
|
| 63 | + public function set_source_store( Store $store ) { |
|
| 64 | + $this->source_store = $store; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Get the configured source loger. |
|
| 69 | + * |
|
| 70 | + * @return ActionScheduler_Logger |
|
| 71 | + */ |
|
| 72 | + public function get_source_logger() { |
|
| 73 | + if ( empty( $this->source_logger ) ) { |
|
| 74 | + throw new \RuntimeException( __( 'Source logger must be configured before running a migration', 'action-scheduler' ) ); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + return $this->source_logger; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Set the configured source logger. |
|
| 82 | + * |
|
| 83 | + * @param ActionScheduler_Logger $logger |
|
| 84 | + */ |
|
| 85 | + public function set_source_logger( Logger $logger ) { |
|
| 86 | + $this->source_logger = $logger; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Get the configured destination store. |
|
| 91 | + * |
|
| 92 | + * @return ActionScheduler_Store |
|
| 93 | + */ |
|
| 94 | + public function get_destination_store() { |
|
| 95 | + if ( empty( $this->destination_store ) ) { |
|
| 96 | + throw new \RuntimeException( __( 'Destination store must be configured before running a migration', 'action-scheduler' ) ); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + return $this->destination_store; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Set the configured destination store. |
|
| 104 | + * |
|
| 105 | + * @param ActionScheduler_Store $store |
|
| 106 | + */ |
|
| 107 | + public function set_destination_store( Store $store ) { |
|
| 108 | + $this->destination_store = $store; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Get the configured destination logger. |
|
| 113 | + * |
|
| 114 | + * @return ActionScheduler_Logger |
|
| 115 | + */ |
|
| 116 | + public function get_destination_logger() { |
|
| 117 | + if ( empty( $this->destination_logger ) ) { |
|
| 118 | + throw new \RuntimeException( __( 'Destination logger must be configured before running a migration', 'action-scheduler' ) ); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + return $this->destination_logger; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Set the configured destination logger. |
|
| 126 | + * |
|
| 127 | + * @param ActionScheduler_Logger $logger |
|
| 128 | + */ |
|
| 129 | + public function set_destination_logger( Logger $logger ) { |
|
| 130 | + $this->destination_logger = $logger; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Get flag indicating whether it's a dry run. |
|
| 135 | + * |
|
| 136 | + * @return bool |
|
| 137 | + */ |
|
| 138 | + public function get_dry_run() { |
|
| 139 | + return $this->dry_run; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Set flag indicating whether it's a dry run. |
|
| 144 | + * |
|
| 145 | + * @param bool $dry_run |
|
| 146 | + */ |
|
| 147 | + public function set_dry_run( $dry_run ) { |
|
| 148 | + $this->dry_run = (bool) $dry_run; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Get progress bar object. |
|
| 153 | + * |
|
| 154 | + * @return ActionScheduler\WPCLI\ProgressBar |
|
| 155 | + */ |
|
| 156 | + public function get_progress_bar() { |
|
| 157 | + return $this->progress_bar; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * Set progress bar object. |
|
| 162 | + * |
|
| 163 | + * @param ActionScheduler\WPCLI\ProgressBar $progress_bar |
|
| 164 | + */ |
|
| 165 | + public function set_progress_bar( ProgressBar $progress_bar ) { |
|
| 166 | + $this->progress_bar = $progress_bar; |
|
| 167 | + } |
|
| 168 | 168 | } |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | * @return ActionScheduler_Store |
| 49 | 49 | */ |
| 50 | 50 | public function get_source_store() { |
| 51 | - if ( empty( $this->source_store ) ) { |
|
| 52 | - throw new \RuntimeException( __( 'Source store must be configured before running a migration', 'action-scheduler' ) ); |
|
| 51 | + if (empty($this->source_store)) { |
|
| 52 | + throw new \RuntimeException(__('Source store must be configured before running a migration', 'action-scheduler')); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | return $this->source_store; |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param ActionScheduler_Store $store Source store object. |
| 62 | 62 | */ |
| 63 | - public function set_source_store( Store $store ) { |
|
| 63 | + public function set_source_store(Store $store) { |
|
| 64 | 64 | $this->source_store = $store; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | * @return ActionScheduler_Logger |
| 71 | 71 | */ |
| 72 | 72 | public function get_source_logger() { |
| 73 | - if ( empty( $this->source_logger ) ) { |
|
| 74 | - throw new \RuntimeException( __( 'Source logger must be configured before running a migration', 'action-scheduler' ) ); |
|
| 73 | + if (empty($this->source_logger)) { |
|
| 74 | + throw new \RuntimeException(__('Source logger must be configured before running a migration', 'action-scheduler')); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | return $this->source_logger; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @param ActionScheduler_Logger $logger |
| 84 | 84 | */ |
| 85 | - public function set_source_logger( Logger $logger ) { |
|
| 85 | + public function set_source_logger(Logger $logger) { |
|
| 86 | 86 | $this->source_logger = $logger; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | * @return ActionScheduler_Store |
| 93 | 93 | */ |
| 94 | 94 | public function get_destination_store() { |
| 95 | - if ( empty( $this->destination_store ) ) { |
|
| 96 | - throw new \RuntimeException( __( 'Destination store must be configured before running a migration', 'action-scheduler' ) ); |
|
| 95 | + if (empty($this->destination_store)) { |
|
| 96 | + throw new \RuntimeException(__('Destination store must be configured before running a migration', 'action-scheduler')); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | return $this->destination_store; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @param ActionScheduler_Store $store |
| 106 | 106 | */ |
| 107 | - public function set_destination_store( Store $store ) { |
|
| 107 | + public function set_destination_store(Store $store) { |
|
| 108 | 108 | $this->destination_store = $store; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | * @return ActionScheduler_Logger |
| 115 | 115 | */ |
| 116 | 116 | public function get_destination_logger() { |
| 117 | - if ( empty( $this->destination_logger ) ) { |
|
| 118 | - throw new \RuntimeException( __( 'Destination logger must be configured before running a migration', 'action-scheduler' ) ); |
|
| 117 | + if (empty($this->destination_logger)) { |
|
| 118 | + throw new \RuntimeException(__('Destination logger must be configured before running a migration', 'action-scheduler')); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | return $this->destination_logger; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @param ActionScheduler_Logger $logger |
| 128 | 128 | */ |
| 129 | - public function set_destination_logger( Logger $logger ) { |
|
| 129 | + public function set_destination_logger(Logger $logger) { |
|
| 130 | 130 | $this->destination_logger = $logger; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @param bool $dry_run |
| 146 | 146 | */ |
| 147 | - public function set_dry_run( $dry_run ) { |
|
| 147 | + public function set_dry_run($dry_run) { |
|
| 148 | 148 | $this->dry_run = (bool) $dry_run; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @param ActionScheduler\WPCLI\ProgressBar $progress_bar |
| 164 | 164 | */ |
| 165 | - public function set_progress_bar( ProgressBar $progress_bar ) { |
|
| 165 | + public function set_progress_bar(ProgressBar $progress_bar) { |
|
| 166 | 166 | $this->progress_bar = $progress_bar; |
| 167 | 167 | } |
| 168 | 168 | } |