From 45786f1d72dd8e3816b9eb6269704b1f61b4772a Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Thu, 25 Jul 2024 15:52:00 +0530 Subject: [PATCH] improve query; remove meta first and then posts (only subc) --- uninstall.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/uninstall.php b/uninstall.php index 07cba68f0..11fb05a68 100644 --- a/uninstall.php +++ b/uninstall.php @@ -30,9 +30,11 @@ function dt_delete_data() { // Remove transients. $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '_transient\_dt\_%';" ); - // Delete subscription data from the post and post meta tables. + // Delete post meta entries where the post type is 'dt_subscription' + $wpdb->query( "DELETE meta FROM $wpdb->postmeta meta LEFT JOIN $wpdb->posts posts ON posts.ID = meta.post_id WHERE posts.post_type IN ( 'dt_subscription' );" ); + + // Delete posts of type 'dt_subscription' $wpdb->query( "DELETE FROM $wpdb->posts WHERE post_type IN ( 'dt_subscription' );" ); - $wpdb->query( "DELETE meta FROM $wpdb->postmeta meta LEFT JOIN $wpdb->posts posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" ); // Clear cache. wp_cache_set_posts_last_changed();