Remove no-op migration from 8.0.

This commit is contained in:
barryhughes 2023-08-04 09:30:37 -07:00
parent d64e1c24dd
commit 3f58ac3e5b
3 changed files with 5 additions and 55 deletions

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Removes a migration that previously targeted 8.0.0. Nothing to communicate to end-users.

View File

@ -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',
),
);
/**

View File

@ -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;
}