From bdd9349c378bc690a68c49d05651c6996eeb8825 Mon Sep 17 00:00:00 2001 From: Antonio Sejas Date: Tue, 14 Oct 2025 14:59:17 +0100 Subject: [PATCH 1/3] Rethrow the error when the encoding is correct but the import query failed --- src/Import.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Import.php b/src/Import.php index de13bb0..93b2f92 100644 --- a/src/Import.php +++ b/src/Import.php @@ -61,6 +61,9 @@ protected function execute_statements( $import_file ) { $converted_statement = mb_convert_encoding( $statement, 'UTF-8', $detected_encoding ); echo 'Converted ecoding for statement: ' . $converted_statement . PHP_EOL; $this->driver->query( $converted_statement ); + } else { + // It's not a encoding issue, so rethrow the exception. + throw $e; } } catch ( Exception $e ) { WP_CLI::warning( 'Could not execute statement: ' . $statement ); From e1aee887e98b4e57a695e3858db556bec0e8641f Mon Sep 17 00:00:00 2001 From: Antonio Sejas Date: Tue, 14 Oct 2025 15:04:47 +0100 Subject: [PATCH 2/3] Fix comment --- src/Import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Import.php b/src/Import.php index 93b2f92..bf5e52d 100644 --- a/src/Import.php +++ b/src/Import.php @@ -62,7 +62,7 @@ protected function execute_statements( $import_file ) { echo 'Converted ecoding for statement: ' . $converted_statement . PHP_EOL; $this->driver->query( $converted_statement ); } else { - // It's not a encoding issue, so rethrow the exception. + // It's not an encoding issue, so rethrow the exception. throw $e; } } catch ( Exception $e ) { From 88994e948da4376532f80d1bad6a3554c2592ac7 Mon Sep 17 00:00:00 2001 From: Antonio Sejas Date: Tue, 14 Oct 2025 15:31:02 +0100 Subject: [PATCH 3/3] Display an error when the query fails instead of a warning --- src/Import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Import.php b/src/Import.php index bf5e52d..e2e8249 100644 --- a/src/Import.php +++ b/src/Import.php @@ -66,7 +66,7 @@ protected function execute_statements( $import_file ) { throw $e; } } catch ( Exception $e ) { - WP_CLI::warning( 'Could not execute statement: ' . $statement ); + WP_CLI::error( 'Could not execute statement: ' . $statement ); echo $e->getMessage(); } }