From 2561aad87ef1eb76b80d1c95d5f8cbaa041b872d Mon Sep 17 00:00:00 2001 From: Mike Straw Date: Thu, 12 Sep 2024 09:57:58 -0400 Subject: [PATCH] Check for existence of AutomateWoo and Action Scheduler tables before modifying data --- includes/scrub-options.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/scrub-options.php b/includes/scrub-options.php index c7f533e..492e951 100644 --- a/includes/scrub-options.php +++ b/includes/scrub-options.php @@ -93,9 +93,17 @@ function( $v ) use ( $modules_to_disable ) { // Disable AutomateWoo workflows, clear the queue, and set scheduled actions to "done" $wpdb->query( "UPDATE $wpdb->posts SET post_status = 'aw-disabled' WHERE post_type = 'aw_workflow' AND post_status = 'publish'" ); - $wpdb->query( "DELETE FROM {$wpdb->prefix}automatewoo_queue" ); - $wpdb->query( "DELETE FROM {$wpdb->prefix}automatewoo_queue_meta" ); - $wpdb->query( "UPDATE {$wpdb->prefix}actionscheduler_actions SET status = 'done' WHERE status = 'pending' AND hook LIKE '%automatewoo%'" ); + + $table_name = $wpdb->prefix . 'automatewoo_queue'; + if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) === $table_name ) { + $wpdb->query( "DELETE FROM {$wpdb->prefix}automatewoo_queue" ); + $wpdb->query( "DELETE FROM {$wpdb->prefix}automatewoo_queue_meta" ); + } + + $table_name = $wpdb->prefix . 'actionscheduler_actions'; + if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) === $table_name ) { + $wpdb->query( "UPDATE {$wpdb->prefix}actionscheduler_actions SET status = 'done' WHERE status = 'pending' AND hook LIKE '%automatewoo%'" ); + } update_option( 'safety_net_options_scrubbed', true );