From 39e6497a3d8a52a901a927d6dfaeda0f5ca65ccf Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 19:27:49 -0400 Subject: [PATCH 01/19] eliminate WordPress.WhiteSpace.PrecisionAlignment smells --- classes/ActionScheduler_ActionClaim.php | 1 - classes/ActionScheduler_NullLogEntry.php | 1 - classes/ActionScheduler_Versions.php | 1 - classes/actions/ActionScheduler_FinishedAction.php | 1 - classes/actions/ActionScheduler_NullAction.php | 1 - .../ActionScheduler_wpPostStore_PostTypeRegistrar.php | 1 - .../ActionScheduler_wpPostStore_TaxonomyRegistrar.php | 1 - classes/schedules/ActionScheduler_Schedule.php | 1 - 8 files changed, 8 deletions(-) diff --git a/classes/ActionScheduler_ActionClaim.php b/classes/ActionScheduler_ActionClaim.php index 8b5681620..692fb3dea 100644 --- a/classes/ActionScheduler_ActionClaim.php +++ b/classes/ActionScheduler_ActionClaim.php @@ -20,4 +20,3 @@ public function get_actions() { return $this->action_ids; } } - \ No newline at end of file diff --git a/classes/ActionScheduler_NullLogEntry.php b/classes/ActionScheduler_NullLogEntry.php index 6f8f218aa..01cb76bc9 100644 --- a/classes/ActionScheduler_NullLogEntry.php +++ b/classes/ActionScheduler_NullLogEntry.php @@ -8,4 +8,3 @@ public function __construct( $action_id = '', $message = '' ) { // nothing to see here } } - \ No newline at end of file diff --git a/classes/ActionScheduler_Versions.php b/classes/ActionScheduler_Versions.php index 915c2e632..23d696198 100644 --- a/classes/ActionScheduler_Versions.php +++ b/classes/ActionScheduler_Versions.php @@ -59,4 +59,3 @@ public static function initialize_latest_version() { call_user_func($self->latest_version_callback()); } } - \ No newline at end of file diff --git a/classes/actions/ActionScheduler_FinishedAction.php b/classes/actions/ActionScheduler_FinishedAction.php index b23a56c66..fe6878fbb 100644 --- a/classes/actions/ActionScheduler_FinishedAction.php +++ b/classes/actions/ActionScheduler_FinishedAction.php @@ -13,4 +13,3 @@ public function is_finished() { return TRUE; } } - \ No newline at end of file diff --git a/classes/actions/ActionScheduler_NullAction.php b/classes/actions/ActionScheduler_NullAction.php index cd5dc3b0f..be0899e22 100644 --- a/classes/actions/ActionScheduler_NullAction.php +++ b/classes/actions/ActionScheduler_NullAction.php @@ -13,4 +13,3 @@ public function execute() { // don't execute } } - \ No newline at end of file diff --git a/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php b/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php index e1bcf6bea..0666547d3 100644 --- a/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php +++ b/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php @@ -47,4 +47,3 @@ protected function post_type_args() { return $args; } } - \ No newline at end of file diff --git a/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php b/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php index 367401f7e..cb22f2fef 100644 --- a/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php +++ b/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php @@ -23,4 +23,3 @@ protected function taxonomy_args() { return $args; } } - \ No newline at end of file diff --git a/classes/schedules/ActionScheduler_Schedule.php b/classes/schedules/ActionScheduler_Schedule.php index d61a9f7c9..5e67afacb 100644 --- a/classes/schedules/ActionScheduler_Schedule.php +++ b/classes/schedules/ActionScheduler_Schedule.php @@ -15,4 +15,3 @@ public function next( DateTime $after = NULL ); */ public function is_recurring(); } - \ No newline at end of file From fb3a59f138a5398b55e8e842311675ab8428a4c0 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 19:31:01 -0400 Subject: [PATCH 02/19] eliminate WordPress.WhiteSpace.OperatorSpacing smells --- classes/ActionScheduler_FatalErrorMonitor.php | 2 +- classes/ActionScheduler_LogEntry.php | 4 ++-- classes/ActionScheduler_Versions.php | 2 +- classes/abstracts/ActionScheduler.php | 2 +- classes/abstracts/ActionScheduler_TimezoneHelper.php | 2 +- classes/data-stores/ActionScheduler_wpCommentLogger.php | 6 +++--- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/classes/ActionScheduler_FatalErrorMonitor.php b/classes/ActionScheduler_FatalErrorMonitor.php index 5fa67d681..e44c6464b 100644 --- a/classes/ActionScheduler_FatalErrorMonitor.php +++ b/classes/ActionScheduler_FatalErrorMonitor.php @@ -44,7 +44,7 @@ public function untrack_action() { public function handle_unexpected_shutdown() { if ( $error = error_get_last() ) { if ( in_array( $error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR ) ) ) { - if ( !empty($this->action_id) ) { + if ( ! empty($this->action_id) ) { $this->store->mark_failure( $this->action_id ); do_action( 'action_scheduler_unexpected_shutdown', $this->action_id, $error ); } diff --git a/classes/ActionScheduler_LogEntry.php b/classes/ActionScheduler_LogEntry.php index 649636deb..9ac57210e 100644 --- a/classes/ActionScheduler_LogEntry.php +++ b/classes/ActionScheduler_LogEntry.php @@ -8,12 +8,12 @@ class ActionScheduler_LogEntry { /** * @var int $action_id */ - protected $action_id = ''; + protected $action_id = ''; /** * @var string $message */ - protected $message = ''; + protected $message = ''; /** * @var Datetime $date diff --git a/classes/ActionScheduler_Versions.php b/classes/ActionScheduler_Versions.php index 23d696198..281a79d28 100644 --- a/classes/ActionScheduler_Versions.php +++ b/classes/ActionScheduler_Versions.php @@ -34,7 +34,7 @@ public function latest_version() { public function latest_version_callback() { $latest = $this->latest_version(); - if ( empty($latest) || !isset($this->versions[$latest]) ) { + if ( empty($latest) || ! isset($this->versions[$latest]) ) { return '__return_null'; } return $this->versions[$latest]; diff --git a/classes/abstracts/ActionScheduler.php b/classes/abstracts/ActionScheduler.php index 0163f7072..bfa2c0601 100644 --- a/classes/abstracts/ActionScheduler.php +++ b/classes/abstracts/ActionScheduler.php @@ -15,7 +15,7 @@ abstract class ActionScheduler { private static $data_store_initialized = false; public static function factory() { - if ( !isset(self::$factory) ) { + if ( ! isset(self::$factory) ) { self::$factory = new ActionScheduler_ActionFactory(); } return self::$factory; diff --git a/classes/abstracts/ActionScheduler_TimezoneHelper.php b/classes/abstracts/ActionScheduler_TimezoneHelper.php index 36529181d..4f66d5175 100644 --- a/classes/abstracts/ActionScheduler_TimezoneHelper.php +++ b/classes/abstracts/ActionScheduler_TimezoneHelper.php @@ -104,7 +104,7 @@ public static function get_local_timezone( $reset = FALSE ) { if ( $reset ) { self::$local_timezone = NULL; } - if ( !isset(self::$local_timezone) ) { + if ( ! isset(self::$local_timezone) ) { $tzstring = get_option('timezone_string'); if ( empty($tzstring) ) { diff --git a/classes/data-stores/ActionScheduler_wpCommentLogger.php b/classes/data-stores/ActionScheduler_wpCommentLogger.php index 7215ddd94..6ec4569e5 100644 --- a/classes/data-stores/ActionScheduler_wpCommentLogger.php +++ b/classes/data-stores/ActionScheduler_wpCommentLogger.php @@ -76,7 +76,7 @@ public function get_logs( $action_id ) { $logs = array(); foreach ( $comments as $c ) { $entry = $this->get_entry( $c ); - if ( !empty($entry) ) { + if ( ! empty($entry) ) { $logs[] = $entry; } } @@ -94,7 +94,7 @@ protected function get_comment( $comment_id ) { */ public function filter_comment_queries( $query ) { foreach ( array('ID', 'parent', 'post_author', 'post_name', 'post_parent', 'type', 'post_type', 'post_id', 'post_ID') as $key ) { - if ( !empty($query->query_vars[$key]) ) { + if ( ! empty($query->query_vars[$key]) ) { return; // don't slow down queries that wouldn't include action_log comments anyway } } @@ -109,7 +109,7 @@ public function filter_comment_queries( $query ) { * @return array */ public function filter_comment_query_clauses( $clauses, $query ) { - if ( !empty($query->query_vars['action_log_filter']) ) { + if ( ! empty($query->query_vars['action_log_filter']) ) { $clauses['where'] .= $this->get_where_clause(); } return $clauses; From e3be4bb038195f09da5796f13a4ecb9dd9e7f53a Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 19:32:57 -0400 Subject: [PATCH 03/19] eliminate WordPress.WhiteSpace.ControlStructureSpacing smells --- classes/migration/ActionScheduler_DBStoreMigrator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/migration/ActionScheduler_DBStoreMigrator.php b/classes/migration/ActionScheduler_DBStoreMigrator.php index ae0785d44..74514e2e3 100644 --- a/classes/migration/ActionScheduler_DBStoreMigrator.php +++ b/classes/migration/ActionScheduler_DBStoreMigrator.php @@ -23,7 +23,7 @@ class ActionScheduler_DBStoreMigrator extends ActionScheduler_DBStore { * @return string The action ID * @throws \RuntimeException When the action is not saved. */ - public function save_action( ActionScheduler_Action $action, \DateTime $scheduled_date = null, \DateTime $last_attempt_date = null ){ + public function save_action( ActionScheduler_Action $action, \DateTime $scheduled_date = null, \DateTime $last_attempt_date = null ) { try { /** @var \wpdb $wpdb */ global $wpdb; From af4f5a51b7f1214fdff82863e4a715427e71bf24 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 19:51:41 -0400 Subject: [PATCH 04/19] eliminate WordPress.Security.EscapeOutput smells --- classes/ActionScheduler_AdminView.php | 18 ++++++++++++------ classes/abstracts/ActionScheduler.php | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/classes/ActionScheduler_AdminView.php b/classes/ActionScheduler_AdminView.php index ed30950a7..cdb701757 100644 --- a/classes/ActionScheduler_AdminView.php +++ b/classes/ActionScheduler_AdminView.php @@ -193,13 +193,19 @@ protected function check_pastdue_actions() { echo '

'; printf( // translators: 1) is the number of affected actions, 2) is a link to an admin screen. - _n( - 'Action Scheduler: %1$d past-due action found; something may be wrong. Read documentation »', - 'Action Scheduler: %1$d past-due actions found; something may be wrong. Read documentation »', - $num_pastdue_actions, - 'action-scheduler' + wp_kses( + _n( + 'Action Scheduler: %1$d past-due action found; something may be wrong. Read documentation »', + 'Action Scheduler: %1$d past-due actions found; something may be wrong. Read documentation »', + $num_pastdue_actions, + 'action-scheduler' + ), + array( + 'strong' => array(), + 'a' => array( 'href', 'target' ), + ) ), - $num_pastdue_actions, + absint( $num_pastdue_actions ), esc_attr( esc_url( $actions_url ) ) ); echo '

'; diff --git a/classes/abstracts/ActionScheduler.php b/classes/abstracts/ActionScheduler.php index bfa2c0601..2b8d01ade 100644 --- a/classes/abstracts/ActionScheduler.php +++ b/classes/abstracts/ActionScheduler.php @@ -226,7 +226,7 @@ public static function is_initialized( $function_name = null ) { __( '%s() was called before the Action Scheduler data store was initialized', 'action-scheduler' ), esc_attr( $function_name ) ); - _doing_it_wrong( $function_name, $message, '3.1.6' ); + _doing_it_wrong( esc_html( $function_name ), esc_html( $message ), '3.1.6' ); } return self::$data_store_initialized; From 2352610a6c714fc5691a88ea2f9ddc7352a79500 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 19:52:19 -0400 Subject: [PATCH 05/19] eliminate WordPress.WP.CronInterval smells --- classes/ActionScheduler_QueueRunner.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/ActionScheduler_QueueRunner.php b/classes/ActionScheduler_QueueRunner.php index 90e64fc46..525ff277b 100644 --- a/classes/ActionScheduler_QueueRunner.php +++ b/classes/ActionScheduler_QueueRunner.php @@ -51,6 +51,7 @@ public function __construct( ActionScheduler_Store $store = null, ActionSchedule */ public function init() { + // phpcs:ignore WordPress.WP.CronInterval.CronSchedulesInterval add_filter( 'cron_schedules', array( self::instance(), 'add_wp_cron_schedule' ) ); // Check for and remove any WP Cron hook scheduled by Action Scheduler < 3.0.0, which didn't include the $context param From 1c3d753ab3982411e2b648d4d40c926137feeb74 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 19:57:08 -0400 Subject: [PATCH 06/19] eliminate WordPress.PHP.YodaConditions smells --- classes/ActionScheduler_QueueCleaner.php | 6 +++--- classes/WP_CLI/ActionScheduler_WPCLI_Clean_Command.php | 2 +- classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php | 2 +- classes/abstracts/ActionScheduler_TimezoneHelper.php | 4 ++-- classes/data-stores/ActionScheduler_wpCommentLogger.php | 2 +- classes/migration/ActionMigrator.php | 2 +- classes/migration/Scheduler.php | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/classes/ActionScheduler_QueueCleaner.php b/classes/ActionScheduler_QueueCleaner.php index 6b066dca0..7adb57ece 100644 --- a/classes/ActionScheduler_QueueCleaner.php +++ b/classes/ActionScheduler_QueueCleaner.php @@ -87,8 +87,8 @@ public function delete_old_actions() { * @return array Actions deleted. */ public function clean_actions( array $statuses_to_purge, DateTime $cutoff_date, $batch_size = null, $context = 'old' ) { - $batch_size = $batch_size !== null ? $batch_size : $this->batch_size; - $cutoff = $cutoff_date !== null ? $cutoff_date : as_get_datetime_object( $this->month_in_seconds . ' seconds ago' ); + $batch_size = ! is_null( $batch_size ) ? $batch_size : $this->batch_size; + $cutoff = ! is_null( $cutoff_date ) ? $cutoff_date : as_get_datetime_object( $this->month_in_seconds . ' seconds ago' ); $lifespan = time() - $cutoff->getTimestamp(); if ( empty( $statuses_to_purge ) ) { $statuses_to_purge = $this->default_statuses_to_purge; @@ -118,7 +118,7 @@ public function clean_actions( array $statuses_to_purge, DateTime $cutoff_date, */ private function delete_actions( array $actions_to_delete, $lifespan = null, $context = 'old' ) { $deleted_actions = []; - if ( $lifespan === null ) { + if ( is_null( $lifespan ) ) { $lifespan = $this->month_in_seconds; } diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Clean_Command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Clean_Command.php index ff6e57aa3..53ea09b02 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_Clean_Command.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_Clean_Command.php @@ -41,7 +41,7 @@ public function clean( $args, $assoc_args ) { $batches_completed = 0; $actions_deleted = 0; - $unlimited = $batches === 0; + $unlimited = 0 === $batches; try { $lifespan = as_get_datetime_object( $before ); } catch ( Exception $e ) { diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php index 2c68a3860..63a1948f4 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php @@ -91,7 +91,7 @@ public function run( $args, $assoc_args ) { $batches_completed = 0; $actions_completed = 0; - $unlimited = $batches === 0; + $unlimited = 0 === $batches; if ( is_callable( [ ActionScheduler::store(), 'set_claim_filter' ] ) ) { $exclude_groups = $this->parse_comma_separated_string( $exclude_groups ); diff --git a/classes/abstracts/ActionScheduler_TimezoneHelper.php b/classes/abstracts/ActionScheduler_TimezoneHelper.php index 4f66d5175..2969b09e8 100644 --- a/classes/abstracts/ActionScheduler_TimezoneHelper.php +++ b/classes/abstracts/ActionScheduler_TimezoneHelper.php @@ -108,8 +108,8 @@ public static function get_local_timezone( $reset = FALSE ) { $tzstring = get_option('timezone_string'); if ( empty($tzstring) ) { - $gmt_offset = get_option('gmt_offset'); - if ( $gmt_offset == 0 ) { + $gmt_offset = absint( get_option('gmt_offset') ); + if ( 0 === $gmt_offset ) { $tzstring = 'UTC'; } else { $gmt_offset *= HOUR_IN_SECONDS; diff --git a/classes/data-stores/ActionScheduler_wpCommentLogger.php b/classes/data-stores/ActionScheduler_wpCommentLogger.php index 6ec4569e5..6ad4502c5 100644 --- a/classes/data-stores/ActionScheduler_wpCommentLogger.php +++ b/classes/data-stores/ActionScheduler_wpCommentLogger.php @@ -47,7 +47,7 @@ protected function create_wp_comment( $action_id, $message, DateTime $date ) { */ public function get_entry( $entry_id ) { $comment = $this->get_comment( $entry_id ); - if ( empty($comment) || $comment->comment_type != self::TYPE ) { + if ( empty($comment) || self::TYPE !== $comment->comment_type ) { return new ActionScheduler_NullLogEntry(); } diff --git a/classes/migration/ActionMigrator.php b/classes/migration/ActionMigrator.php index 1469de02f..64b94e31a 100644 --- a/classes/migration/ActionMigrator.php +++ b/classes/migration/ActionMigrator.php @@ -68,7 +68,7 @@ public function migrate( $source_action_id ) { try { // Make sure the last attempt date is set correctly for completed and failed actions - $last_attempt_date = ( $status !== \ActionScheduler_Store::STATUS_PENDING ) ? $this->source->get_date( $source_action_id ) : null; + $last_attempt_date = ( \ActionScheduler_Store::STATUS_PENDING !== $status ) ? $this->source->get_date( $source_action_id ) : null; $destination_action_id = $this->destination->save_action( $action, null, $last_attempt_date ); } catch ( \Exception $e ) { diff --git a/classes/migration/Scheduler.php b/classes/migration/Scheduler.php index dcbe2db5f..9649aad97 100644 --- a/classes/migration/Scheduler.php +++ b/classes/migration/Scheduler.php @@ -40,7 +40,7 @@ public function run_migration() { $migration_runner = $this->get_migration_runner(); $count = $migration_runner->run( $this->get_batch_size() ); - if ( $count === 0 ) { + if ( 0 === $count ) { $this->mark_complete(); } else { $this->schedule_migration( time() + $this->get_schedule_interval() ); From b7a1002857cb348ea67d9caa364b1128bbdb3d70 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 20:00:31 -0400 Subject: [PATCH 07/19] eliminate WordPress.PHP.StrictInArray smells --- classes/ActionScheduler_FatalErrorMonitor.php | 2 +- classes/ActionScheduler_ListTable.php | 4 ++-- classes/ActionScheduler_QueueRunner.php | 2 +- classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php | 2 +- classes/abstracts/ActionScheduler_Store.php | 2 +- classes/data-stores/ActionScheduler_DBStore.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/classes/ActionScheduler_FatalErrorMonitor.php b/classes/ActionScheduler_FatalErrorMonitor.php index e44c6464b..fa2da3215 100644 --- a/classes/ActionScheduler_FatalErrorMonitor.php +++ b/classes/ActionScheduler_FatalErrorMonitor.php @@ -43,7 +43,7 @@ public function untrack_action() { public function handle_unexpected_shutdown() { if ( $error = error_get_last() ) { - if ( in_array( $error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR ) ) ) { + if ( in_array( $error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR ), true ) ) { if ( ! empty($this->action_id) ) { $this->store->mark_failure( $this->action_id ); do_action( 'action_scheduler_unexpected_shutdown', $this->action_id, $error ); diff --git a/classes/ActionScheduler_ListTable.php b/classes/ActionScheduler_ListTable.php index abf767ce6..9f8342efa 100644 --- a/classes/ActionScheduler_ListTable.php +++ b/classes/ActionScheduler_ListTable.php @@ -118,7 +118,7 @@ public function __construct( ActionScheduler_Store $store, ActionScheduler_Logge if ( empty( $request_status ) ) { $this->sort_by[] = 'status'; - } elseif ( in_array( $request_status, array( 'in-progress', 'failed' ) ) ) { + } elseif ( in_array( $request_status, array( 'in-progress', 'failed' ), true ) ) { $this->columns += array( 'claim_id' => __( 'Claim ID', 'action-scheduler' ) ); $this->sort_by[] = 'claim_id'; } @@ -358,7 +358,7 @@ public function display_admin_notices() { $found_tables = $wpdb->get_col( "SHOW TABLES LIKE '{$wpdb->prefix}actionscheduler%'" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared foreach ( $table_list as $table_name ) { - if ( ! in_array( $wpdb->prefix . $table_name, $found_tables ) ) { + if ( ! in_array( $wpdb->prefix . $table_name, $found_tables, true ) ) { $this->admin_notices[] = array( 'class' => 'error', 'message' => __( 'It appears one or more database tables were missing. Attempting to re-create the missing table(s).' , 'action-scheduler' ), diff --git a/classes/ActionScheduler_QueueRunner.php b/classes/ActionScheduler_QueueRunner.php index 525ff277b..8d4c3a76f 100644 --- a/classes/ActionScheduler_QueueRunner.php +++ b/classes/ActionScheduler_QueueRunner.php @@ -164,7 +164,7 @@ protected function do_batch( $size = 100, $context = '' ) { foreach ( $claim->get_actions() as $action_id ) { // bail if we lost the claim - if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $claim->get_id() ) ) ) { + if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $claim->get_id() ), true ) ) { break; } $this->process_action( $action_id, $context ); diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php b/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php index 4681daa49..76134c039 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php @@ -109,7 +109,7 @@ public function run( $context = 'WP CLI' ) { $this->setup_progress_bar(); foreach ( $this->actions as $action_id ) { // Error if we lost the claim. - if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $this->claim->get_id() ) ) ) { + if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $this->claim->get_id() ), true ) ) { WP_CLI::warning( __( 'The claim has been lost. Aborting current batch.', 'action-scheduler' ) ); break; } diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php index 421f5a671..b1296ab90 100644 --- a/classes/abstracts/ActionScheduler_Store.php +++ b/classes/abstracts/ActionScheduler_Store.php @@ -241,7 +241,7 @@ abstract public function find_actions_by_claim_id( $claim_id ); * @return string */ protected function validate_sql_comparator( $comparison_operator ) { - if ( in_array( $comparison_operator, array('!=', '>', '>=', '<', '<=', '=') ) ) { + if ( in_array( $comparison_operator, array('!=', '>', '>=', '<', '<=', '='), true ) ) { return $comparison_operator; } return '='; diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index e19711ebd..697ec36e6 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -222,7 +222,7 @@ private function get_placeholder_for_column( $column_name ) { 'extended_args', ); - return in_array( $column_name, $string_columns ) ? '%s' : '%d'; + return in_array( $column_name, $string_columns, true ) ? '%s' : '%d'; } /** From 1a3d5ce422e5a587af2cd0fdf81a15f38ff68929 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 20:07:00 -0400 Subject: [PATCH 08/19] eliminate WordPress.PHP.StrictComparisons smells --- classes/ActionScheduler_AdminView.php | 4 ++-- classes/ActionScheduler_ListTable.php | 2 +- classes/abstracts/ActionScheduler_TimezoneHelper.php | 2 +- classes/data-stores/ActionScheduler_wpCommentLogger.php | 4 ++-- classes/migration/LogMigrator.php | 2 +- functions.php | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/classes/ActionScheduler_AdminView.php b/classes/ActionScheduler_AdminView.php index cdb701757..9504e732b 100644 --- a/classes/ActionScheduler_AdminView.php +++ b/classes/ActionScheduler_AdminView.php @@ -31,7 +31,7 @@ public static function instance() { * @codeCoverageIgnore */ public function init() { - if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || false == DOING_AJAX ) ) { + if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || false === DOING_AJAX ) ) { if ( class_exists( 'WooCommerce' ) ) { add_action( 'woocommerce_admin_status_content_action-scheduler', array( $this, 'render_admin_ui' ) ); @@ -220,7 +220,7 @@ protected function check_pastdue_actions() { public function add_help_tabs() { $screen = get_current_screen(); - if ( ! $screen || self::$screen_id != $screen->id ) { + if ( ! $screen || self::$screen_id !== $screen->id ) { return; } diff --git a/classes/ActionScheduler_ListTable.php b/classes/ActionScheduler_ListTable.php index 9f8342efa..1d2d630ac 100644 --- a/classes/ActionScheduler_ListTable.php +++ b/classes/ActionScheduler_ListTable.php @@ -413,7 +413,7 @@ public function display_admin_notices() { $action = $this->store->fetch_action( $notification['action_id'] ); $action_hook_html = '' . $action->get_hook() . ''; - if ( 1 == $notification['success'] ) { + if ( 1 === absint( $notification['success'] ) ) { $class = 'updated'; switch ( $notification['row_action_type'] ) { case 'run' : diff --git a/classes/abstracts/ActionScheduler_TimezoneHelper.php b/classes/abstracts/ActionScheduler_TimezoneHelper.php index 2969b09e8..66a97ece6 100644 --- a/classes/abstracts/ActionScheduler_TimezoneHelper.php +++ b/classes/abstracts/ActionScheduler_TimezoneHelper.php @@ -125,7 +125,7 @@ public static function get_local_timezone( $reset = FALSE ) { $is_dst = date( 'I' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date -- we are actually interested in the runtime timezone. foreach ( timezone_abbreviations_list() as $abbr ) { foreach ( $abbr as $city ) { - if ( $city['dst'] == $is_dst && $city['offset'] == $gmt_offset ) { + if ( absint( $city['dst'] ) === $is_dst && absint( $city['offset'] ) === $gmt_offset ) { // If there's no valid timezone ID, keep looking. if ( null === $city['timezone_id'] ) { continue; diff --git a/classes/data-stores/ActionScheduler_wpCommentLogger.php b/classes/data-stores/ActionScheduler_wpCommentLogger.php index 6ad4502c5..f189ec2f3 100644 --- a/classes/data-stores/ActionScheduler_wpCommentLogger.php +++ b/classes/data-stores/ActionScheduler_wpCommentLogger.php @@ -63,7 +63,7 @@ public function get_entry( $entry_id ) { */ public function get_logs( $action_id ) { $status = 'all'; - if ( get_post_status($action_id) == 'trash' ) { + if ( get_post_status($action_id) === 'trash' ) { $status = 'post-trashed'; } $comments = get_comments(array( @@ -180,7 +180,7 @@ protected function get_comment_count() { foreach ( (array) $count as $row ) { // Don't count post-trashed toward totals - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { + if ( 'post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved'] ) { $total += $row['num_comments']; } if ( isset( $approved[ $row['comment_approved'] ] ) ) { diff --git a/classes/migration/LogMigrator.php b/classes/migration/LogMigrator.php index b85da8550..01e47622e 100644 --- a/classes/migration/LogMigrator.php +++ b/classes/migration/LogMigrator.php @@ -41,7 +41,7 @@ public function __construct( ActionScheduler_Logger $source_logger, ActionSchedu public function migrate( $source_action_id, $destination_action_id ) { $logs = $this->source->get_logs( $source_action_id ); foreach ( $logs as $log ) { - if ( $log->get_action_id() == $source_action_id ) { + if ( $log->get_action_id() === $source_action_id ) { $this->destination->log( $destination_action_id, $log->get_message(), $log->get_date() ); } } diff --git a/functions.php b/functions.php index 66bc54ff5..0bf53a1e7 100644 --- a/functions.php +++ b/functions.php @@ -126,7 +126,7 @@ function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, // We expect an integer and allow it to be passed using float and string types, but otherwise // should reject unexpected values. - if ( ! is_numeric( $interval_in_seconds ) || $interval_in_seconds != $interval ) { + if ( ! is_numeric( $interval_in_seconds ) || $interval_in_seconds !== $interval ) { _doing_it_wrong( __METHOD__, sprintf( @@ -455,7 +455,7 @@ function as_get_scheduled_actions( $args = array(), $return_format = OBJECT ) { $actions[ $action_id ] = $store->fetch_action( $action_id ); } - if ( ARRAY_A == $return_format ) { + if ( ARRAY_A === $return_format ) { foreach ( $actions as $action_id => $action_object ) { $actions[ $action_id ] = get_object_vars( $action_object ); } From d5451c7fe4de82f1c412c94a89f3a16f241af575 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 20:15:43 -0400 Subject: [PATCH 09/19] eliminate some WordPress.PHP.DevelopmentFunctions smells --- classes/ActionScheduler_InvalidActionException.php | 4 ++-- classes/WP_CLI/Migration_Command.php | 1 + classes/abstracts/ActionScheduler.php | 4 ++-- classes/abstracts/ActionScheduler_Abstract_QueueRunner.php | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/ActionScheduler_InvalidActionException.php b/classes/ActionScheduler_InvalidActionException.php index 40b455993..53865f26c 100644 --- a/classes/ActionScheduler_InvalidActionException.php +++ b/classes/ActionScheduler_InvalidActionException.php @@ -20,7 +20,7 @@ public static function from_schedule( $action_id, $schedule ) { /* translators: 1: action ID 2: schedule */ __( 'Action [%1$s] has an invalid schedule: %2$s', 'action-scheduler' ), $action_id, - var_export( $schedule, true ) + var_export( $schedule, true ) // phpcs:ignore WordPress.PHP.DevelopmentFunctions ); return new static( $message ); @@ -39,7 +39,7 @@ public static function from_decoding_args( $action_id, $args = array() ) { /* translators: 1: action ID 2: arguments */ __( 'Action [%1$s] has invalid arguments. It cannot be JSON decoded to an array. $args = %2$s', 'action-scheduler' ), $action_id, - var_export( $args, true ) + var_export( $args, true ) // phpcs:ignore WordPress.PHP.DevelopmentFunctions ); return new static( $message ); diff --git a/classes/WP_CLI/Migration_Command.php b/classes/WP_CLI/Migration_Command.php index 066697e4e..c48d4daba 100644 --- a/classes/WP_CLI/Migration_Command.php +++ b/classes/WP_CLI/Migration_Command.php @@ -139,6 +139,7 @@ private function init_logging() { WP_CLI::debug( sprintf( 'Migrated source action with ID %d to new store with ID %d', $source_id, $destination_id ) ); }, 10, 2 ); add_action( 'action_scheduler/migration_batch_starting', function ( $batch ) { + // phpcs:ignore WordPress.PHP.DevelopmentFunctions WP_CLI::debug( 'Beginning migration of batch: ' . print_r( $batch, true ) ); }, 10, 1 ); add_action( 'action_scheduler/migration_batch_complete', function ( $batch ) { diff --git a/classes/abstracts/ActionScheduler.php b/classes/abstracts/ActionScheduler.php index 2b8d01ade..8a1c2a0d8 100644 --- a/classes/abstracts/ActionScheduler.php +++ b/classes/abstracts/ActionScheduler.php @@ -309,11 +309,11 @@ protected static function is_class_cli( $class ) { } final public function __clone() { - trigger_error("Singleton. No cloning allowed!", E_USER_ERROR); + wp_trigger_error("Singleton. No cloning allowed!", E_USER_ERROR); } final public function __wakeup() { - trigger_error("Singleton. No serialization allowed!", E_USER_ERROR); + wp_trigger_error("Singleton. No serialization allowed!", E_USER_ERROR); } final private function __construct() {} diff --git a/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php b/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php index 371917e3c..1f50f7885 100644 --- a/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php +++ b/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php @@ -49,6 +49,7 @@ public function __construct( ActionScheduler_Store $store = null, ActionSchedule */ public function process_action( $action_id, $context = '' ) { // Temporarily override the error handler while we process the current action. + // phpcs:ignore WordPress.PHP.DevelopmentFunctions set_error_handler( /** * Temporary error handler which can catch errors and convert them into exceptions. This facilitates more From cfafb3b4884a5a9af4a9c72812a970fb680fd901 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 20:17:45 -0400 Subject: [PATCH 10/19] eliminate WordPress.NamingConventions.ValidVariableName smells --- classes/ActionScheduler_DateTime.php | 8 ++++---- classes/migration/LogMigrator.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/classes/ActionScheduler_DateTime.php b/classes/ActionScheduler_DateTime.php index b142ca81c..49660a6aa 100644 --- a/classes/ActionScheduler_DateTime.php +++ b/classes/ActionScheduler_DateTime.php @@ -15,7 +15,7 @@ class ActionScheduler_DateTime extends DateTime { * * @var int */ - protected $utcOffset = 0; + protected $utc_offset = 0; /** * Get the unix timestamp of the current object. @@ -37,7 +37,7 @@ public function getTimestamp() { * @param $offset */ public function setUtcOffset( $offset ) { - $this->utcOffset = intval( $offset ); + $this->utc_offset = intval( $offset ); } /** @@ -48,7 +48,7 @@ public function setUtcOffset( $offset ) { */ #[\ReturnTypeWillChange] public function getOffset() { - return $this->utcOffset ? $this->utcOffset : parent::getOffset(); + return $this->utc_offset ? $this->utc_offset : parent::getOffset(); } /** @@ -61,7 +61,7 @@ public function getOffset() { */ #[\ReturnTypeWillChange] public function setTimezone( $timezone ) { - $this->utcOffset = 0; + $this->utc_offset = 0; parent::setTimezone( $timezone ); return $this; diff --git a/classes/migration/LogMigrator.php b/classes/migration/LogMigrator.php index 01e47622e..9274212b5 100644 --- a/classes/migration/LogMigrator.php +++ b/classes/migration/LogMigrator.php @@ -25,11 +25,11 @@ class LogMigrator { * ActionMigrator constructor. * * @param ActionScheduler_Logger $source_logger Source logger object. - * @param ActionScheduler_Logger $destination_Logger Destination logger object. + * @param ActionScheduler_Logger $destination_logger Destination logger object. */ - public function __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_Logger ) { + public function __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_logger ) { $this->source = $source_logger; - $this->destination = $destination_Logger; + $this->destination = $destination_logger; } /** From 0d0ec58ee9838f5e6a908150448e8eed2dfb5a4e Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 20:21:19 -0400 Subject: [PATCH 11/19] eliminate WordPress.CodeAnalysis.AssignmentInCondition smells --- classes/ActionScheduler_FatalErrorMonitor.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/ActionScheduler_FatalErrorMonitor.php b/classes/ActionScheduler_FatalErrorMonitor.php index fa2da3215..6de202823 100644 --- a/classes/ActionScheduler_FatalErrorMonitor.php +++ b/classes/ActionScheduler_FatalErrorMonitor.php @@ -42,7 +42,9 @@ public function untrack_action() { } public function handle_unexpected_shutdown() { - if ( $error = error_get_last() ) { + $error = error_get_last(); + + if ( $error ) { if ( in_array( $error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR ), true ) ) { if ( ! empty($this->action_id) ) { $this->store->mark_failure( $this->action_id ); From b9abf807d96674a579a015110bb961c66770636f Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 20:22:00 -0400 Subject: [PATCH 12/19] eliminate WordPress.Classes.ClassInstantiation smells --- classes/ActionScheduler_LogEntry.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/ActionScheduler_LogEntry.php b/classes/ActionScheduler_LogEntry.php index 9ac57210e..8cc00d2ed 100644 --- a/classes/ActionScheduler_LogEntry.php +++ b/classes/ActionScheduler_LogEntry.php @@ -44,7 +44,7 @@ public function __construct( $action_id, $message, $date = null ) { $this->action_id = $action_id; $this->message = $message; - $this->date = $date ? $date : new Datetime; + $this->date = $date ? $date : new Datetime(); } /** From deb901ed43eaf6df276c50693f310d66969d2669 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 20:25:27 -0400 Subject: [PATCH 13/19] eliminate WordPress.Arrays.MultipleStatementAlignment smells --- classes/ActionScheduler_AdminView.php | 2 +- classes/ActionScheduler_ListTable.php | 6 +-- .../ActionScheduler_wpCommentLogger.php | 18 ++++---- ...cheduler_wpPostStore_PostTypeRegistrar.php | 42 +++++++++---------- ...cheduler_wpPostStore_TaxonomyRegistrar.php | 10 ++--- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/classes/ActionScheduler_AdminView.php b/classes/ActionScheduler_AdminView.php index 9504e732b..efa159ab8 100644 --- a/classes/ActionScheduler_AdminView.php +++ b/classes/ActionScheduler_AdminView.php @@ -202,7 +202,7 @@ protected function check_pastdue_actions() { ), array( 'strong' => array(), - 'a' => array( 'href', 'target' ), + 'a' => array( 'href', 'target' ), ) ), absint( $num_pastdue_actions ), diff --git a/classes/ActionScheduler_ListTable.php b/classes/ActionScheduler_ListTable.php index 1d2d630ac..d97759a08 100644 --- a/classes/ActionScheduler_ListTable.php +++ b/classes/ActionScheduler_ListTable.php @@ -125,9 +125,9 @@ public function __construct( ActionScheduler_Store $store, ActionScheduler_Logge $this->row_actions = array( 'hook' => array( - 'run' => array( - 'name' => __( 'Run', 'action-scheduler' ), - 'desc' => __( 'Process the action now as if it were run as part of a queue', 'action-scheduler' ), + 'run' => array( + 'name' => __( 'Run', 'action-scheduler' ), + 'desc' => __( 'Process the action now as if it were run as part of a queue', 'action-scheduler' ), ), 'cancel' => array( 'name' => __( 'Cancel', 'action-scheduler' ), diff --git a/classes/data-stores/ActionScheduler_wpCommentLogger.php b/classes/data-stores/ActionScheduler_wpCommentLogger.php index f189ec2f3..d1c1f557b 100644 --- a/classes/data-stores/ActionScheduler_wpCommentLogger.php +++ b/classes/data-stores/ActionScheduler_wpCommentLogger.php @@ -29,13 +29,13 @@ protected function create_wp_comment( $action_id, $message, DateTime $date ) { $comment_date_gmt = $date->format('Y-m-d H:i:s'); ActionScheduler_TimezoneHelper::set_local_timezone( $date ); $comment_data = array( - 'comment_post_ID' => $action_id, - 'comment_date' => $date->format('Y-m-d H:i:s'), + 'comment_post_ID' => $action_id, + 'comment_date' => $date->format('Y-m-d H:i:s'), 'comment_date_gmt' => $comment_date_gmt, - 'comment_author' => self::AGENT, - 'comment_content' => $message, - 'comment_agent' => self::AGENT, - 'comment_type' => self::TYPE, + 'comment_author' => self::AGENT, + 'comment_content' => $message, + 'comment_agent' => self::AGENT, + 'comment_type' => self::TYPE, ); return wp_insert_comment($comment_data); } @@ -69,9 +69,9 @@ public function get_logs( $action_id ) { $comments = get_comments(array( 'post_id' => $action_id, 'orderby' => 'comment_date_gmt', - 'order' => 'ASC', - 'type' => self::TYPE, - 'status' => $status, + 'order' => 'ASC', + 'type' => self::TYPE, + 'status' => $status, )); $logs = array(); foreach ( $comments as $c ) { diff --git a/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php b/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php index 0666547d3..e46316f6c 100644 --- a/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php +++ b/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php @@ -16,29 +16,29 @@ public function register() { */ protected function post_type_args() { $args = array( - 'label' => __( 'Scheduled Actions', 'action-scheduler' ), - 'description' => __( 'Scheduled actions are hooks triggered on a certain date and time.', 'action-scheduler' ), - 'public' => false, + 'label' => __( 'Scheduled Actions', 'action-scheduler' ), + 'description' => __( 'Scheduled actions are hooks triggered on a certain date and time.', 'action-scheduler' ), + 'public' => false, 'map_meta_cap' => true, 'hierarchical' => false, - 'supports' => array('title', 'editor','comments'), - 'rewrite' => false, - 'query_var' => false, - 'can_export' => true, - 'ep_mask' => EP_NONE, - 'labels' => array( - 'name' => __( 'Scheduled Actions', 'action-scheduler' ), - 'singular_name' => __( 'Scheduled Action', 'action-scheduler' ), - 'menu_name' => _x( 'Scheduled Actions', 'Admin menu name', 'action-scheduler' ), - 'add_new' => __( 'Add', 'action-scheduler' ), - 'add_new_item' => __( 'Add New Scheduled Action', 'action-scheduler' ), - 'edit' => __( 'Edit', 'action-scheduler' ), - 'edit_item' => __( 'Edit Scheduled Action', 'action-scheduler' ), - 'new_item' => __( 'New Scheduled Action', 'action-scheduler' ), - 'view' => __( 'View Action', 'action-scheduler' ), - 'view_item' => __( 'View Action', 'action-scheduler' ), - 'search_items' => __( 'Search Scheduled Actions', 'action-scheduler' ), - 'not_found' => __( 'No actions found', 'action-scheduler' ), + 'supports' => array('title', 'editor','comments'), + 'rewrite' => false, + 'query_var' => false, + 'can_export' => true, + 'ep_mask' => EP_NONE, + 'labels' => array( + 'name' => __( 'Scheduled Actions', 'action-scheduler' ), + 'singular_name' => __( 'Scheduled Action', 'action-scheduler' ), + 'menu_name' => _x( 'Scheduled Actions', 'Admin menu name', 'action-scheduler' ), + 'add_new' => __( 'Add', 'action-scheduler' ), + 'add_new_item' => __( 'Add New Scheduled Action', 'action-scheduler' ), + 'edit' => __( 'Edit', 'action-scheduler' ), + 'edit_item' => __( 'Edit Scheduled Action', 'action-scheduler' ), + 'new_item' => __( 'New Scheduled Action', 'action-scheduler' ), + 'view' => __( 'View Action', 'action-scheduler' ), + 'view_item' => __( 'View Action', 'action-scheduler' ), + 'search_items' => __( 'Search Scheduled Actions', 'action-scheduler' ), + 'not_found' => __( 'No actions found', 'action-scheduler' ), 'not_found_in_trash' => __( 'No actions found in trash', 'action-scheduler' ), ), ); diff --git a/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php b/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php index cb22f2fef..9498dfc93 100644 --- a/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php +++ b/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php @@ -11,12 +11,12 @@ public function register() { protected function taxonomy_args() { $args = array( - 'label' => __( 'Action Group', 'action-scheduler' ), - 'public' => false, - 'hierarchical' => false, + 'label' => __( 'Action Group', 'action-scheduler' ), + 'public' => false, + 'hierarchical' => false, 'show_admin_column' => true, - 'query_var' => false, - 'rewrite' => false, + 'query_var' => false, + 'rewrite' => false, ); $args = apply_filters( 'action_scheduler_taxonomy_args', $args ); From 4c4a21905a9ec1d844db9831aaf2b742845dc3a1 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 20:27:24 -0400 Subject: [PATCH 14/19] eliminate WordPress.Arrays.CommaAfterArrayItem smells --- classes/abstracts/ActionScheduler_Abstract_QueueRunner.php | 2 +- .../abstracts/ActionScheduler_Abstract_RecurringSchedule.php | 2 +- .../ActionScheduler_wpPostStore_PostTypeRegistrar.php | 2 +- classes/schedules/ActionScheduler_CronSchedule.php | 2 +- classes/schedules/ActionScheduler_IntervalSchedule.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php b/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php index 1f50f7885..8aa024c15 100644 --- a/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php +++ b/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php @@ -193,7 +193,7 @@ private function recurring_action_is_consistently_failing( ActionScheduler_Actio 'date' => date_create( 'now', timezone_open( 'UTC' ) )->format( 'Y-m-d H:i:s' ), 'date_compare' => '<', 'per_page' => 1, - 'offset' => $consistent_failure_threshold - 1 + 'offset' => $consistent_failure_threshold - 1, ); $first_failing_action_id = $this->store->query_actions( $query_args ); diff --git a/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php b/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php index 0ed8bc8e5..3480a65f7 100644 --- a/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php +++ b/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php @@ -77,7 +77,7 @@ public function __sleep() { $this->first_timestamp = $this->first_date->getTimestamp(); return array_merge( $sleep_params, array( 'first_timestamp', - 'recurrence' + 'recurrence', ) ); } diff --git a/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php b/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php index e46316f6c..d4d4b6759 100644 --- a/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php +++ b/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php @@ -21,7 +21,7 @@ protected function post_type_args() { 'public' => false, 'map_meta_cap' => true, 'hierarchical' => false, - 'supports' => array('title', 'editor','comments'), + 'supports' => array('title', 'editor', 'comments'), 'rewrite' => false, 'query_var' => false, 'can_export' => true, diff --git a/classes/schedules/ActionScheduler_CronSchedule.php b/classes/schedules/ActionScheduler_CronSchedule.php index bc70c0f24..9fad3707a 100644 --- a/classes/schedules/ActionScheduler_CronSchedule.php +++ b/classes/schedules/ActionScheduler_CronSchedule.php @@ -77,7 +77,7 @@ public function __sleep() { return array_merge( $sleep_params, array( 'start_timestamp', - 'cron' + 'cron', ) ); } diff --git a/classes/schedules/ActionScheduler_IntervalSchedule.php b/classes/schedules/ActionScheduler_IntervalSchedule.php index ba4d508df..85aecb731 100644 --- a/classes/schedules/ActionScheduler_IntervalSchedule.php +++ b/classes/schedules/ActionScheduler_IntervalSchedule.php @@ -57,7 +57,7 @@ public function __sleep() { return array_merge( $sleep_params, array( 'start_timestamp', - 'interval_in_seconds' + 'interval_in_seconds', ) ); } From 8ca4c4c5642a5512f374764f8bb4ffe1dbed72e8 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 20:30:17 -0400 Subject: [PATCH 15/19] eliminate WordPress.Arrays.ArrayKeySpacingRestrictions smells --- classes/ActionScheduler_ListTable.php | 2 +- classes/ActionScheduler_Versions.php | 8 ++++---- classes/WP_CLI/Migration_Command.php | 8 ++++---- classes/abstracts/ActionScheduler.php | 6 +++--- classes/data-stores/ActionScheduler_wpCommentLogger.php | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/classes/ActionScheduler_ListTable.php b/classes/ActionScheduler_ListTable.php index d97759a08..fdbf2ac2d 100644 --- a/classes/ActionScheduler_ListTable.php +++ b/classes/ActionScheduler_ListTable.php @@ -330,7 +330,7 @@ protected function get_log_entry_html( ActionScheduler_LogEntry $log_entry, Date * @return string */ protected function maybe_render_actions( $row, $column_name ) { - if ( 'pending' === strtolower( $row[ 'status_name' ] ) ) { + if ( 'pending' === strtolower( $row['status_name'] ) ) { return parent::maybe_render_actions( $row, $column_name ); } diff --git a/classes/ActionScheduler_Versions.php b/classes/ActionScheduler_Versions.php index 281a79d28..afcb2de57 100644 --- a/classes/ActionScheduler_Versions.php +++ b/classes/ActionScheduler_Versions.php @@ -12,10 +12,10 @@ class ActionScheduler_Versions { private $versions = array(); public function register( $version_string, $initialization_callback ) { - if ( isset($this->versions[$version_string]) ) { + if ( isset($this->versions[ $version_string ]) ) { return FALSE; } - $this->versions[$version_string] = $initialization_callback; + $this->versions[ $version_string ] = $initialization_callback; return TRUE; } @@ -34,10 +34,10 @@ public function latest_version() { public function latest_version_callback() { $latest = $this->latest_version(); - if ( empty($latest) || ! isset($this->versions[$latest]) ) { + if ( empty($latest) || ! isset($this->versions[ $latest ]) ) { return '__return_null'; } - return $this->versions[$latest]; + return $this->versions[ $latest ]; } /** diff --git a/classes/WP_CLI/Migration_Command.php b/classes/WP_CLI/Migration_Command.php index c48d4daba..e2c975a34 100644 --- a/classes/WP_CLI/Migration_Command.php +++ b/classes/WP_CLI/Migration_Command.php @@ -81,9 +81,9 @@ public function migrate( $positional_args, $assoc_args ) { $runner = new Runner( $config ); $runner->init_destination(); - $batch_size = isset( $assoc_args[ 'batch-size' ] ) ? (int) $assoc_args[ 'batch-size' ] : 100; - $free_on = isset( $assoc_args[ 'free-memory-on' ] ) ? (int) $assoc_args[ 'free-memory-on' ] : 50; - $sleep = isset( $assoc_args[ 'pause' ] ) ? (int) $assoc_args[ 'pause' ] : 0; + $batch_size = isset( $assoc_args['batch-size'] ) ? (int) $assoc_args['batch-size'] : 100; + $free_on = isset( $assoc_args['free-memory-on'] ) ? (int) $assoc_args['free-memory-on'] : 50; + $sleep = isset( $assoc_args['pause'] ) ? (int) $assoc_args['pause'] : 0; \ActionScheduler_DataController::set_free_ticks( $free_on ); \ActionScheduler_DataController::set_sleep_time( $sleep ); @@ -114,7 +114,7 @@ private function get_migration_config( $args ) { ] ); $config = Controller::instance()->get_migration_config_object(); - $config->set_dry_run( ! empty( $args[ 'dry-run' ] ) ); + $config->set_dry_run( ! empty( $args['dry-run'] ) ); return $config; } diff --git a/classes/abstracts/ActionScheduler.php b/classes/abstracts/ActionScheduler.php index 8a1c2a0d8..dfc32c6b9 100644 --- a/classes/abstracts/ActionScheduler.php +++ b/classes/abstracts/ActionScheduler.php @@ -91,7 +91,7 @@ public static function autoload( $class ) { $dir = $classes_dir . 'schema' . $d; } elseif ( strpos( $class, 'ActionScheduler' ) === 0 ) { $segments = explode( '_', $class ); - $type = isset( $segments[ 1 ] ) ? $segments[ 1 ] : ''; + $type = isset( $segments[1] ) ? $segments[1] : ''; switch ( $type ) { case 'WPCLI': @@ -281,7 +281,7 @@ protected static function is_class_migration( $class ) { ); $segments = explode( '_', $class ); - $segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class; + $segment = isset( $segments[1] ) ? $segments[1] : $class; return isset( $migration_segments[ $segment ] ) && $migration_segments[ $segment ]; } @@ -303,7 +303,7 @@ protected static function is_class_cli( $class ) { ); $segments = explode( '_', $class ); - $segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class; + $segment = isset( $segments[1] ) ? $segments[1] : $class; return isset( $cli_segments[ $segment ] ) && $cli_segments[ $segment ]; } diff --git a/classes/data-stores/ActionScheduler_wpCommentLogger.php b/classes/data-stores/ActionScheduler_wpCommentLogger.php index d1c1f557b..f680777d4 100644 --- a/classes/data-stores/ActionScheduler_wpCommentLogger.php +++ b/classes/data-stores/ActionScheduler_wpCommentLogger.php @@ -94,7 +94,7 @@ protected function get_comment( $comment_id ) { */ public function filter_comment_queries( $query ) { foreach ( array('ID', 'parent', 'post_author', 'post_name', 'post_parent', 'type', 'post_type', 'post_id', 'post_ID') as $key ) { - if ( ! empty($query->query_vars[$key]) ) { + if ( ! empty($query->query_vars[ $key ]) ) { return; // don't slow down queries that wouldn't include action_log comments anyway } } From 4f2236266830419e086c98021ec50f564eae3dfb Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 20:30:57 -0400 Subject: [PATCH 16/19] eliminate WordPress.Arrays.ArrayIndentation smells --- classes/data-stores/ActionScheduler_DBStore.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index 697ec36e6..6398e084c 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -411,7 +411,7 @@ protected function get_query_actions_sql( array $query, $select_or_count = 'sele 'offset' => 0, 'orderby' => 'date', 'order' => 'ASC', - ) ); + ) ); /** @var \wpdb $wpdb */ global $wpdb; From bd99172540d68aa79860d5b3a1fad83f2c4e936a Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 20:34:08 -0400 Subject: [PATCH 17/19] eliminate WordPress.Arrays.ArrayDeclarationSpacing smells --- classes/ActionScheduler_WPCommentCleaner.php | 13 ++++++++++--- classes/abstracts/ActionScheduler_Store.php | 2 +- .../data-stores/ActionScheduler_wpCommentLogger.php | 10 ++++++++-- ...ctionScheduler_wpPostStore_PostTypeRegistrar.php | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/classes/ActionScheduler_WPCommentCleaner.php b/classes/ActionScheduler_WPCommentCleaner.php index 1ba552c50..4cf7da5b3 100644 --- a/classes/ActionScheduler_WPCommentCleaner.php +++ b/classes/ActionScheduler_WPCommentCleaner.php @@ -66,7 +66,11 @@ public static function has_logs() { * Attached to the migration complete hook 'action_scheduler/migration_complete'. */ public static function maybe_schedule_cleanup() { - if ( (bool) get_comments( array( 'type' => ActionScheduler_wpCommentLogger::TYPE, 'number' => 1, 'fields' => 'ids' ) ) ) { + if ( (bool) get_comments( array( + 'type' => ActionScheduler_wpCommentLogger::TYPE, + 'number' => 1, + 'fields' => 'ids', + ) ) ) { update_option( self::$has_logs_option_key, 'yes' ); if ( ! as_next_scheduled_action( self::$cleanup_hook ) ) { @@ -80,7 +84,10 @@ public static function maybe_schedule_cleanup() { */ public static function delete_all_action_comments() { global $wpdb; - $wpdb->delete( $wpdb->comments, array( 'comment_type' => ActionScheduler_wpCommentLogger::TYPE, 'comment_agent' => ActionScheduler_wpCommentLogger::AGENT ) ); + $wpdb->delete( $wpdb->comments, array( + 'comment_type' => ActionScheduler_wpCommentLogger::TYPE, + 'comment_agent' => ActionScheduler_wpCommentLogger::AGENT, + ) ); delete_option( self::$has_logs_option_key ); } @@ -90,7 +97,7 @@ public static function delete_all_action_comments() { public static function register_admin_notice() { add_action( 'admin_notices', array( __CLASS__, 'print_admin_notice' ) ); } - + /** * Prints details about the orphaned action logs and includes information on where to learn more. */ diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php index b1296ab90..546d72fba 100644 --- a/classes/abstracts/ActionScheduler_Store.php +++ b/classes/abstracts/ActionScheduler_Store.php @@ -241,7 +241,7 @@ abstract public function find_actions_by_claim_id( $claim_id ); * @return string */ protected function validate_sql_comparator( $comparison_operator ) { - if ( in_array( $comparison_operator, array('!=', '>', '>=', '<', '<=', '='), true ) ) { + if ( in_array( $comparison_operator, array( '!=', '>', '>=', '<', '<=', '=' ), true ) ) { return $comparison_operator; } return '='; diff --git a/classes/data-stores/ActionScheduler_wpCommentLogger.php b/classes/data-stores/ActionScheduler_wpCommentLogger.php index f680777d4..6d8d7cf93 100644 --- a/classes/data-stores/ActionScheduler_wpCommentLogger.php +++ b/classes/data-stores/ActionScheduler_wpCommentLogger.php @@ -93,7 +93,7 @@ protected function get_comment( $comment_id ) { * @param WP_Comment_Query $query */ public function filter_comment_queries( $query ) { - foreach ( array('ID', 'parent', 'post_author', 'post_name', 'post_parent', 'type', 'post_type', 'post_id', 'post_ID') as $key ) { + foreach ( array( 'ID', 'parent', 'post_author', 'post_name', 'post_parent', 'type', 'post_type', 'post_id', 'post_ID' ) as $key ) { if ( ! empty($query->query_vars[ $key ]) ) { return; // don't slow down queries that wouldn't include action_log comments anyway } @@ -176,7 +176,13 @@ protected function get_comment_count() { $total = 0; $stats = array(); - $approved = array( '0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed' ); + $approved = array( + '0' => 'moderated', + '1' => 'approved', + 'spam' => 'spam', + 'trash' => 'trash', + 'post-trashed' => 'post-trashed', + ); foreach ( (array) $count as $row ) { // Don't count post-trashed toward totals diff --git a/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php b/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php index d4d4b6759..a93f4b241 100644 --- a/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php +++ b/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php @@ -21,7 +21,7 @@ protected function post_type_args() { 'public' => false, 'map_meta_cap' => true, 'hierarchical' => false, - 'supports' => array('title', 'editor', 'comments'), + 'supports' => array( 'title', 'editor', 'comments' ), 'rewrite' => false, 'query_var' => false, 'can_export' => true, From 1ad9418bb9d54dfdb0bd734b43f408d0b04d8a19 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 2 Aug 2024 20:38:01 -0400 Subject: [PATCH 18/19] eliminate WooCommerce.Commenting.CommentTags smells --- .../ActionScheduler_AsyncRequest_QueueRunner.php | 3 --- classes/ActionScheduler_InvalidActionException.php | 2 -- classes/ActionScheduler_QueueCleaner.php | 2 -- .../WP_CLI/ActionScheduler_WPCLI_QueueRunner.php | 14 -------------- .../ActionScheduler_WPCLI_Scheduler_command.php | 8 -------- .../ActionScheduler_Abstract_QueueRunner.php | 3 --- classes/migration/Controller.php | 2 -- 7 files changed, 34 deletions(-) diff --git a/classes/ActionScheduler_AsyncRequest_QueueRunner.php b/classes/ActionScheduler_AsyncRequest_QueueRunner.php index 57706a24c..52d308968 100644 --- a/classes/ActionScheduler_AsyncRequest_QueueRunner.php +++ b/classes/ActionScheduler_AsyncRequest_QueueRunner.php @@ -14,7 +14,6 @@ class ActionScheduler_AsyncRequest_QueueRunner extends WP_Async_Request { * Data store for querying actions * * @var ActionScheduler_Store - * @access protected */ protected $store; @@ -22,7 +21,6 @@ class ActionScheduler_AsyncRequest_QueueRunner extends WP_Async_Request { * Prefix for ajax hooks * * @var string - * @access protected */ protected $prefix = 'as'; @@ -30,7 +28,6 @@ class ActionScheduler_AsyncRequest_QueueRunner extends WP_Async_Request { * Action for ajax hooks * * @var string - * @access protected */ protected $action = 'async_request_queue_runner'; diff --git a/classes/ActionScheduler_InvalidActionException.php b/classes/ActionScheduler_InvalidActionException.php index 53865f26c..749947d7a 100644 --- a/classes/ActionScheduler_InvalidActionException.php +++ b/classes/ActionScheduler_InvalidActionException.php @@ -29,8 +29,6 @@ public static function from_schedule( $action_id, $schedule ) { /** * Create a new exception when the action's args cannot be decoded to an array. * - * @author Jeremy Pry - * * @param string $action_id The action ID with bad args. * @return static */ diff --git a/classes/ActionScheduler_QueueCleaner.php b/classes/ActionScheduler_QueueCleaner.php index 7adb57ece..8e9c190aa 100644 --- a/classes/ActionScheduler_QueueCleaner.php +++ b/classes/ActionScheduler_QueueCleaner.php @@ -208,7 +208,6 @@ public function mark_failures( $time_limit = 300 ) { * Do all of the cleaning actions. * * @param int $time_limit The number of seconds to use as the timeout and failure period. Default 300 (5 minutes). - * @author Jeremy Pry */ public function clean( $time_limit = 300 ) { $this->delete_old_actions(); @@ -219,7 +218,6 @@ public function clean( $time_limit = 300 ) { /** * Get the batch size for cleaning the queue. * - * @author Jeremy Pry * @return int */ protected function get_batch_size() { diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php b/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php index 76134c039..dfcfaa02c 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php @@ -39,8 +39,6 @@ public function __construct( ActionScheduler_Store $store = null, ActionSchedule /** * Set up the Queue before processing. * - * @author Jeremy Pry - * * @param int $batch_size The batch size to process. * @param array $hooks The hooks being used to filter the actions claimed in this batch. * @param string $group The group of actions to claim with this batch. @@ -72,8 +70,6 @@ public function setup( $batch_size, $hooks = array(), $group = '', $force = fals /** * Add our hooks to the appropriate actions. - * - * @author Jeremy Pry */ protected function add_hooks() { add_action( 'action_scheduler_before_execute', array( $this, 'before_execute' ) ); @@ -83,8 +79,6 @@ protected function add_hooks() { /** * Set up the WP CLI progress bar. - * - * @author Jeremy Pry */ protected function setup_progress_bar() { $count = count( $this->actions ); @@ -98,8 +92,6 @@ protected function setup_progress_bar() { /** * Process actions in the queue. * - * @author Jeremy Pry - * * @param string $context Optional runner context. Default 'WP CLI'. * * @return int The number of actions processed. @@ -129,8 +121,6 @@ public function run( $context = 'WP CLI' ) { /** * Handle WP CLI message when the action is starting. * - * @author Jeremy Pry - * * @param $action_id */ public function before_execute( $action_id ) { @@ -141,8 +131,6 @@ public function before_execute( $action_id ) { /** * Handle WP CLI message when the action has completed. * - * @author Jeremy Pry - * * @param int $action_id * @param null|ActionScheduler_Action $action The instance of the action. Default to null for backward compatibility. */ @@ -158,8 +146,6 @@ public function after_execute( $action_id, $action = null ) { /** * Handle WP CLI message when the action has failed. * - * @author Jeremy Pry - * * @param int $action_id * @param Exception $exception * @throws \WP_CLI\ExitException With failure message. diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php index 63a1948f4..0fbdf071e 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php @@ -141,8 +141,6 @@ private function parse_comma_separated_string( $string ): array { /** * Print WP CLI message about how many actions are about to be processed. * - * @author Jeremy Pry - * * @param int $total */ protected function print_total_actions( $total ) { @@ -158,8 +156,6 @@ protected function print_total_actions( $total ) { /** * Print WP CLI message about how many batches of actions were processed. * - * @author Jeremy Pry - * * @param int $batches_completed */ protected function print_total_batches( $batches_completed ) { @@ -175,8 +171,6 @@ protected function print_total_batches( $batches_completed ) { /** * Convert an exception into a WP CLI error. * - * @author Jeremy Pry - * * @param Exception $e The error object. * * @throws \WP_CLI\ExitException @@ -194,8 +188,6 @@ protected function print_error( Exception $e ) { /** * Print a success message with the number of completed actions. * - * @author Jeremy Pry - * * @param int $actions_completed */ protected function print_success( $actions_completed ) { diff --git a/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php b/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php index 8aa024c15..be6aecf4c 100644 --- a/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php +++ b/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php @@ -223,8 +223,6 @@ private function recurring_action_is_consistently_failing( ActionScheduler_Actio /** * Run the queue cleaner. - * - * @author Jeremy Pry */ protected function run_cleanup() { $this->cleaner->clean( 10 * $this->get_time_limit() ); @@ -364,7 +362,6 @@ protected function batch_limits_exceeded( $processed_actions ) { /** * Process actions in the queue. * - * @author Jeremy Pry * @param string $context Optional identifier for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron' * Generally, this should be capitalised and not localised as it's a proper noun. * @return int The number of actions processed. diff --git a/classes/migration/Controller.php b/classes/migration/Controller.php index b2b618d8f..d01302052 100644 --- a/classes/migration/Controller.php +++ b/classes/migration/Controller.php @@ -178,8 +178,6 @@ private function hook() { /** * Possibly hook the migration scheduler action. - * - * @author Jeremy Pry */ public function maybe_hook_migration() { if ( ! $this->allow_migration() || \ActionScheduler_DataController::is_migration_complete() ) { From 756162d96de2a9279697a16ac7fbf9427d72caa2 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Wed, 7 Aug 2024 20:47:39 -0400 Subject: [PATCH 19/19] eliminate WordPress.PHP.StrictComparisons smells properly --- classes/migration/LogMigrator.php | 2 +- functions.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/migration/LogMigrator.php b/classes/migration/LogMigrator.php index 9274212b5..edc10c4d3 100644 --- a/classes/migration/LogMigrator.php +++ b/classes/migration/LogMigrator.php @@ -41,7 +41,7 @@ public function __construct( ActionScheduler_Logger $source_logger, ActionSchedu public function migrate( $source_action_id, $destination_action_id ) { $logs = $this->source->get_logs( $source_action_id ); foreach ( $logs as $log ) { - if ( $log->get_action_id() === $source_action_id ) { + if ( absint( $log->get_action_id() ) === $source_action_id ) { $this->destination->log( $destination_action_id, $log->get_message(), $log->get_date() ); } } diff --git a/functions.php b/functions.php index 0bf53a1e7..e65376d5f 100644 --- a/functions.php +++ b/functions.php @@ -126,7 +126,8 @@ function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, // We expect an integer and allow it to be passed using float and string types, but otherwise // should reject unexpected values. - if ( ! is_numeric( $interval_in_seconds ) || $interval_in_seconds !== $interval ) { + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison + if ( ! is_numeric( $interval_in_seconds ) || $interval_in_seconds != $interval ) { _doing_it_wrong( __METHOD__, sprintf(