From b74ae199a0006f727b556c7a76e5c72ec27d8de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Thu, 6 Jun 2024 18:35:30 +0200 Subject: [PATCH] Partially revert #117 (#118) There's more nuance to the type of the returned value than #117 antitipated. With that PR in, WooCommerce wouldn't work: ``` [06-Jun-2024 16:21:26 UTC] PHP Fatal error: Uncaught TypeError: get_object_vars(): Argument #1 ($object) must be of type object, string given in /wordpress/wp-includes/class-wpdb.php:3 Stack trace: #0 /wordpress/wp-includes/class-wpdb.php(3): get_object_vars('wp_wc_product_a...') #1 /wordpress/wp-content/plugins/woocommerce/src/Internal/ProductAttributesLookup/LookupDataStore.php(69): wpdb->get_var('SHOW TABLES LIK...') #2 /wordpress/wp-content/plugins/woocommerce/src/Internal/ProductAttributesLookup/LookupDataStore.php(650): Automattic\WooCommerce\Internal\ProductAttributesLookup\LookupDataStore->check_lookup_table_exists() ``` Let's revert and revisit later on cc @bgrgicak @wojtekn --- tests/WP_SQLite_Translator_Tests.php | 4 +++- wp-includes/sqlite/class-wp-sqlite-translator.php | 10 ++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/WP_SQLite_Translator_Tests.php b/tests/WP_SQLite_Translator_Tests.php index b5a65ff4..7a334eeb 100644 --- a/tests/WP_SQLite_Translator_Tests.php +++ b/tests/WP_SQLite_Translator_Tests.php @@ -453,7 +453,9 @@ public function testShowTablesLike() { ); $this->assertEquals( array( - '_tmp_table', + (object) array( + 'Tables_in_db' => '_tmp_table', + ), ), $this->engine->get_query_results() ); diff --git a/wp-includes/sqlite/class-wp-sqlite-translator.php b/wp-includes/sqlite/class-wp-sqlite-translator.php index 7f4b85f3..ac6a170c 100644 --- a/wp-includes/sqlite/class-wp-sqlite-translator.php +++ b/wp-includes/sqlite/class-wp-sqlite-translator.php @@ -3462,10 +3462,7 @@ private function execute_show() { ); $this->set_results_from_fetched_data( - array_column( - $stmt->fetchAll( $this->pdo_fetch_mode ), - 'Tables_in_db' - ) + $stmt->fetchAll( $this->pdo_fetch_mode ) ); return; @@ -3476,10 +3473,7 @@ private function execute_show() { "SELECT name FROM sqlite_master WHERE type='table'" ); $this->set_results_from_fetched_data( - array_column( - $stmt->fetchAll( $this->pdo_fetch_mode ), - 'Tables_in_db' - ) + $stmt->fetchAll( $this->pdo_fetch_mode ) ); return;