From d743c157b371855026366ec181ef098e4823234f Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Tue, 21 Sep 2021 10:01:58 +0200 Subject: [PATCH] Replace usage of "information_schema.tables" This db table is used to check if the product attributes lookup table exists, but that makes WooCommerce uninstallable in WP.COM without a patch. This commit replaces that usage with a "SHOW TABLES LIKE" statement, which is also consistent with other parts of the code. --- .../ProductAttributesLookup/LookupDataStore.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Internal/ProductAttributesLookup/LookupDataStore.php b/src/Internal/ProductAttributesLookup/LookupDataStore.php index 11e3671ad6f..377eb28ee5a 100644 --- a/src/Internal/ProductAttributesLookup/LookupDataStore.php +++ b/src/Internal/ProductAttributesLookup/LookupDataStore.php @@ -130,16 +130,10 @@ class LookupDataStore { public function check_lookup_table_exists() { global $wpdb; - $query = $wpdb->prepare( - 'SELECT count(*) -FROM information_schema.tables -WHERE table_schema = DATABASE() -AND table_name = %s;', - $this->lookup_table_name - ); + $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $this->lookup_table_name ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared - return (bool) $wpdb->get_var( $query ); + return $this->lookup_table_name === $wpdb->get_var( $query ); } /**