diff --git a/plugins/woocommerce/includes/class-wc-install.php b/plugins/woocommerce/includes/class-wc-install.php index 2bac9ea3334..261a9cdf1a2 100644 --- a/plugins/woocommerce/includes/class-wc-install.php +++ b/plugins/woocommerce/includes/class-wc-install.php @@ -1136,6 +1136,17 @@ CREATE TABLE {$wpdb->prefix}wc_product_download_directories ( wc_get_container()->get( DataRegenerator::class )->get_lookup_table_name(), ); + $wca_tables = array( + "{$wpdb->prefix}wc_order_stats", + "{$wpdb->prefix}wc_order_product_lookup", + "{$wpdb->prefix}wc_order_tax_lookup", + "{$wpdb->prefix}wc_order_coupon_lookup", + "{$wpdb->prefix}wc_admin_notes", + "{$wpdb->prefix}wc_admin_note_actions", + "{$wpdb->prefix}wc_customer_lookup", + "{$wpdb->prefix}wc_category_lookup", + ); + /** * Filter the list of known WooCommerce tables. * @@ -1143,7 +1154,7 @@ CREATE TABLE {$wpdb->prefix}wc_product_download_directories ( * * @param array $tables An array of WooCommerce-specific database table names. */ - $tables = apply_filters( 'woocommerce_install_get_tables', $tables ); + $tables = apply_filters( 'woocommerce_install_get_tables', array_merge( $tables, $wca_tables ) ); return $tables; } diff --git a/plugins/woocommerce/src/Internal/Admin/Install.php b/plugins/woocommerce/src/Internal/Admin/Install.php index dc401bc3461..9992d5c0099 100644 --- a/plugins/woocommerce/src/Internal/Admin/Install.php +++ b/plugins/woocommerce/src/Internal/Admin/Install.php @@ -110,10 +110,6 @@ class Install { if ( ( is_admin() && ! wp_doing_ajax() ) || wp_doing_cron() || defined( 'WP_CLI' ) ) { add_action( 'init', array( __CLASS__, 'check_version' ), 5 ); } - add_filter( 'wpmu_drop_tables', array( __CLASS__, 'wpmu_drop_tables' ) ); - - // Add wc-admin report tables to list of WooCommerce tables. - add_filter( 'woocommerce_install_get_tables', array( __CLASS__, 'add_tables' ) ); } /** @@ -394,30 +390,6 @@ class Install { ); } - /** - * Adds new tables. - * - * @param array $wc_tables List of WooCommerce tables. - * @return array - */ - public static function add_tables( $wc_tables ) { - return array_merge( - $wc_tables, - self::get_tables() - ); - } - - /** - * Uninstall tables when MU blog is deleted. - * - * @param array $tables List of tables that will be deleted by WP. - * - * @return string[] - */ - public static function wpmu_drop_tables( $tables ) { - return array_merge( $tables, self::get_tables() ); - } - /** * Get list of DB update callbacks. * @@ -571,21 +543,4 @@ class Install { Notes::delete_notes_with_name( $obsolete_notes_names ); } - - /** - * Drop WooCommerce Admin tables. - * - * @return void - */ - public static function drop_tables() { - global $wpdb; - - $tables = self::get_tables(); - - foreach ( $tables as $table ) { - /* phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared */ - $wpdb->query( "DROP TABLE IF EXISTS {$table}" ); - /* phpcs:enable */ - } - } } diff --git a/plugins/woocommerce/uninstall.php b/plugins/woocommerce/uninstall.php index 425683e0f2f..f77c37dc69b 100644 --- a/plugins/woocommerce/uninstall.php +++ b/plugins/woocommerce/uninstall.php @@ -29,8 +29,6 @@ wp_clear_scheduled_hook( 'woocommerce_cleanup_rate_limits' ); if ( defined( 'WC_REMOVE_ALL_DATA' ) && true === WC_REMOVE_ALL_DATA ) { // Drop WC Admin tables. include_once dirname( __FILE__ ) . '/src/Internal/Admin/Install.php'; - \Automattic\WooCommerce\Internal\Admin\Install::drop_tables(); - include_once dirname( __FILE__ ) . '/includes/class-wc-install.php'; // Roles + caps.