From b0f6bcc8f3cb7622fe0eb74ec3adf981e637fcd1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 19:32:28 +0000 Subject: [PATCH 1/5] Initial plan From a265c7d10eebd12d3f5ce2c33db0be45fc1cc30a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 19:35:24 +0000 Subject: [PATCH 2/5] Fix empty character set parameter issue in mysqlcheck commands Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/db-check.feature | 26 ++++++++++++++++++++++++++ src/DB_Command.php | 9 +++++++++ 2 files changed, 35 insertions(+) diff --git a/features/db-check.feature b/features/db-check.feature index aa5ce47b..7d14a4f7 100644 --- a/features/db-check.feature +++ b/features/db-check.feature @@ -136,3 +136,29 @@ Feature: Check the database When I try `wp db check --no-defaults --debug` Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysqlcheck|mariadb-check) --no-defaults %s# + Scenario: Empty DB credentials should not cause empty parameter errors + Given a WP install + And a wp-config.php file: + """ + Date: Sun, 1 Feb 2026 19:38:21 +0000 Subject: [PATCH 3/5] Address code review feedback: handle null values and improve test Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/db-check.feature | 10 +++++++++- src/DB_Command.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/features/db-check.feature b/features/db-check.feature index 7d14a4f7..c98b3786 100644 --- a/features/db-check.feature +++ b/features/db-check.feature @@ -152,7 +152,15 @@ Feature: Check the database """ When I run `wp db check --debug` - Then STDERR should not contain: + Then STDERR should contain: + """ + Debug (db): Final MySQL command: + """ + And STDERR should not contain: + """ + --default-character-set='' + """ + And STDERR should not contain: """ --default-character-set= """ diff --git a/src/DB_Command.php b/src/DB_Command.php index 2096a0a9..b136169c 100644 --- a/src/DB_Command.php +++ b/src/DB_Command.php @@ -1832,7 +1832,7 @@ private static function run( $cmd, $assoc_args = [], $send_to_shell = true, $int $required = array_filter( $required, static function ( $value ) { - return '' !== $value; + return null !== $value && '' !== $value; } ); From 3a3ed77224be517a7e4962e47c394e151553ecb9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 19:31:01 +0000 Subject: [PATCH 4/5] Move filter to final_args after merge and improve test coverage Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/db-check.feature | 13 ++++--------- src/DB_Command.php | 8 ++++---- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/features/db-check.feature b/features/db-check.feature index c98b3786..216e975c 100644 --- a/features/db-check.feature +++ b/features/db-check.feature @@ -144,9 +144,8 @@ Feature: Check the database define( 'DB_NAME', 'wp_cli_test' ); define( 'DB_USER', 'wp_cli_test' ); define( 'DB_PASSWORD', 'password1' ); - define( 'DB_HOST', 'localhost' ); - define( 'DB_CHARSET', '' ); - define( 'DB_COLLATE', '' ); + define( 'DB_HOST', '' ); + define( 'DB_CHARSET', 'utf8' ); $table_prefix = 'wp_'; require_once ABSPATH . 'wp-settings.php'; """ @@ -158,15 +157,11 @@ Feature: Check the database """ And STDERR should not contain: """ - --default-character-set='' + --host='' """ And STDERR should not contain: """ - --default-character-set= + --host= """ And the return code should be 0 - And STDOUT should contain: - """ - Success: Database checked. - """ diff --git a/src/DB_Command.php b/src/DB_Command.php index b136169c..0595a109 100644 --- a/src/DB_Command.php +++ b/src/DB_Command.php @@ -1827,17 +1827,17 @@ private static function run( $cmd, $assoc_args = [], $send_to_shell = true, $int unset( $assoc_args['dbpass'], $assoc_args['password'] ); } + $final_args = array_merge( $required, $assoc_args ); + // Filter out empty string values to avoid passing empty parameters to MySQL commands // which can cause errors like "Character set '' is not a compiled character set" - $required = array_filter( - $required, + $final_args = array_filter( + $final_args, static function ( $value ) { return null !== $value && '' !== $value; } ); - $final_args = array_merge( $required, $assoc_args ); - // Adapt ordering of arguments. uksort( $final_args, From 6a5eec2ea0ea2a436707540ba8f3219ef25b0d4c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 19:31:54 +0000 Subject: [PATCH 5/5] Add success message assertion to improve test coverage Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/db-check.feature | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/features/db-check.feature b/features/db-check.feature index 216e975c..19bc37ac 100644 --- a/features/db-check.feature +++ b/features/db-check.feature @@ -164,4 +164,8 @@ Feature: Check the database --host= """ And the return code should be 0 + And STDOUT should contain: + """ + Success: Database checked. + """