From 3f58ac3e5b2b318b723cfed0dfe998873c60ae25 Mon Sep 17 00:00:00 2001 From: barryhughes <3594411+barryhughes@users.noreply.github.com> Date: Fri, 4 Aug 2023 09:30:37 -0700 Subject: [PATCH] Remove no-op migration from 8.0. --- .../changelog/remove-wc800-hpos-migration | 5 ++ .../woocommerce/includes/class-wc-install.php | 3 -- .../includes/wc-update-functions.php | 52 ------------------- 3 files changed, 5 insertions(+), 55 deletions(-) create mode 100644 plugins/woocommerce/changelog/remove-wc800-hpos-migration diff --git a/plugins/woocommerce/changelog/remove-wc800-hpos-migration b/plugins/woocommerce/changelog/remove-wc800-hpos-migration new file mode 100644 index 00000000000..6a0da2a91f5 --- /dev/null +++ b/plugins/woocommerce/changelog/remove-wc800-hpos-migration @@ -0,0 +1,5 @@ +Significance: patch +Type: dev +Comment: Removes a migration that previously targeted 8.0.0. Nothing to communicate to end-users. + + diff --git a/plugins/woocommerce/includes/class-wc-install.php b/plugins/woocommerce/includes/class-wc-install.php index bbd391e44cb..7572e0de37f 100644 --- a/plugins/woocommerce/includes/class-wc-install.php +++ b/plugins/woocommerce/includes/class-wc-install.php @@ -238,9 +238,6 @@ class WC_Install { '7.7.0' => array( 'wc_update_770_remove_multichannel_marketing_feature_options', ), - '8.0.0' => array( - 'wc_update_800_delete_stray_order_records', - ), ); /** diff --git a/plugins/woocommerce/includes/wc-update-functions.php b/plugins/woocommerce/includes/wc-update-functions.php index 7c0cf076272..e29e9510a93 100644 --- a/plugins/woocommerce/includes/wc-update-functions.php +++ b/plugins/woocommerce/includes/wc-update-functions.php @@ -2591,55 +2591,3 @@ function wc_update_770_remove_multichannel_marketing_feature_options() { delete_option( 'woocommerce_multichannel_marketing_enabled' ); delete_option( 'woocommerce_marketing_overview_welcome_hidden' ); } - -/** - * Delete posts of type "shop_order_placeholder" with no matching order in the orders table. - */ -function wc_update_800_delete_stray_order_records() { - global $wpdb; - - $orders_table_name = OrdersTableDataStore::get_orders_table_name(); - - // phpcs:disable WordPress.DB.PreparedSQL - - $old_max_id = get_option( 'woocommerce_update_800_delete_stray_order_records_last_processed_id', 0 ); - - if ( 0 === $old_max_id ) { - $suppress = $wpdb->suppress_errors(); - $orders_table_exists = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $orders_table_name ) ) ); - $wpdb->suppress_errors( $suppress ); - - if ( ! $orders_table_exists ) { - return false; - }; - } - - $new_max_id = $wpdb->get_var( - $wpdb->prepare( - "SELECT MAX(id) FROM (SELECT id FROM $orders_table_name WHERE id > %d ORDER BY id LIMIT 10000) x", - $old_max_id - ) - ); - - if ( null === $new_max_id ) { - delete_option( 'woocommerce_update_800_delete_stray_order_records_last_processed_id' ); - return false; - } - - $wpdb->query( - $wpdb->prepare( - "DELETE FROM {$wpdb->posts} WHERE post_type = %s AND ID > %d AND ID <= %d AND ID NOT IN (SELECT id FROM $orders_table_name WHERE id > %d AND id <= %d)", - 'shop_order_placehold', - $old_max_id, - $new_max_id, - $old_max_id, - $new_max_id, - ) - ); - - // phpcs:enable WordPress.DB.PreparedSQL - - update_option( 'woocommerce_update_800_delete_stray_order_records_last_processed_id', $new_max_id ); - - return true; -}