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.
This commit is contained in:
Nestor Soriano 2021-09-21 10:01:58 +02:00
parent 54d134eb07
commit d743c157b3
No known key found for this signature in database
GPG Key ID: 08110F3518C12CAD
1 changed files with 2 additions and 8 deletions

View File

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