Merge pull request #30745 from woocommerce/fix/usage_of_db_information_schema

Replace usage of "information_schema.tables" with "SHOW TABLES LIKE"
This commit is contained in:
jonathansadowski 2021-09-21 11:34:24 -05:00 committed by GitHub
commit f7f8a8d61c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 8 deletions

View File

@ -130,16 +130,10 @@ class LookupDataStore {
public function check_lookup_table_exists() { public function check_lookup_table_exists() {
global $wpdb; global $wpdb;
$query = $wpdb->prepare( $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $this->lookup_table_name ) );
'SELECT count(*)
FROM information_schema.tables
WHERE table_schema = DATABASE()
AND table_name = %s;',
$this->lookup_table_name
);
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
return (bool) $wpdb->get_var( $query ); return $this->lookup_table_name === $wpdb->get_var( $query );
} }
/** /**