From 94513b1a5b0e6e8e1a42acffb9dd75eceb36ec96 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Tue, 13 Aug 2024 11:46:56 -0400 Subject: [PATCH 1/3] set option value to `no` rather than deleting --- classes/ActionScheduler_WPCommentCleaner.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/classes/ActionScheduler_WPCommentCleaner.php b/classes/ActionScheduler_WPCommentCleaner.php index 1ba552c50..8d68133e8 100644 --- a/classes/ActionScheduler_WPCommentCleaner.php +++ b/classes/ActionScheduler_WPCommentCleaner.php @@ -66,13 +66,17 @@ public static function has_logs() { * Attached to the migration complete hook 'action_scheduler/migration_complete'. */ public static function maybe_schedule_cleanup() { + $has_logs = 'no'; + if ( (bool) get_comments( array( 'type' => ActionScheduler_wpCommentLogger::TYPE, 'number' => 1, 'fields' => 'ids' ) ) ) { - update_option( self::$has_logs_option_key, 'yes' ); + $has_logs = 'yes'; if ( ! as_next_scheduled_action( self::$cleanup_hook ) ) { as_schedule_single_action( gmdate( 'U' ) + ( 6 * MONTH_IN_SECONDS ), self::$cleanup_hook ); } } + + update_option( self::$has_logs_option_key, $has_logs ); } /** @@ -81,7 +85,7 @@ 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 ) ); - delete_option( self::$has_logs_option_key ); + update_option( self::$has_logs_option_key, 'no' ); } /** @@ -90,7 +94,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. */ From 767f9a34b645b19edaddd997e25f2d3cc4391617 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 6 Sep 2024 08:16:28 -0400 Subject: [PATCH 2/3] save Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com> --- classes/ActionScheduler_WPCommentCleaner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/ActionScheduler_WPCommentCleaner.php b/classes/ActionScheduler_WPCommentCleaner.php index 6f77b9775..a0f83dcf1 100644 --- a/classes/ActionScheduler_WPCommentCleaner.php +++ b/classes/ActionScheduler_WPCommentCleaner.php @@ -76,7 +76,7 @@ public static function maybe_schedule_cleanup() { } } - update_option( self::$has_logs_option_key, $has_logs ); + update_option( self::$has_logs_option_key, $has_logs, true ); } /** From dee6b0664c0fa7fea17207d89a4e7bde04722d19 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 6 Sep 2024 08:16:34 -0400 Subject: [PATCH 3/3] save Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com> --- classes/ActionScheduler_WPCommentCleaner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/ActionScheduler_WPCommentCleaner.php b/classes/ActionScheduler_WPCommentCleaner.php index a0f83dcf1..4b2a7ddab 100644 --- a/classes/ActionScheduler_WPCommentCleaner.php +++ b/classes/ActionScheduler_WPCommentCleaner.php @@ -85,7 +85,7 @@ 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 ) ); - update_option( self::$has_logs_option_key, 'no' ); + update_option( self::$has_logs_option_key, 'no', true ); } /**