From 237d08fe14277df7392c706033faffb2140b9d99 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 10:21:43 +0000 Subject: [PATCH 1/4] Initial plan From 0814b9cb6fe8d1a8f0b88ea9e7b019121bb02f5e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 10:25:46 +0000 Subject: [PATCH 2/4] Add --quiet support for db check, optimize, and repair commands Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/db-quiet.feature | 109 ++++++++++++++++++++++++++++++++++++++ src/DB_Command.php | 18 +++++++ 2 files changed, 127 insertions(+) create mode 100644 features/db-quiet.feature diff --git a/features/db-quiet.feature b/features/db-quiet.feature new file mode 100644 index 00000000..03a8212a --- /dev/null +++ b/features/db-quiet.feature @@ -0,0 +1,109 @@ +Feature: Quiet mode for database operations + + Scenario: db check with --quiet flag should only show errors + Given a WP install + + When I run `wp db check --quiet` + Then STDOUT should not contain: + """ + wp_cli_test.wp_users + """ + And STDOUT should be empty + + Scenario: db optimize with --quiet flag should only show errors + Given a WP install + + When I run `wp db optimize --quiet` + Then STDOUT should not contain: + """ + wp_cli_test.wp_users + """ + And STDOUT should be empty + + Scenario: db repair with --quiet flag should only show errors + Given a WP install + + When I run `wp db repair --quiet` + Then STDOUT should not contain: + """ + wp_cli_test.wp_users + """ + And STDOUT should be empty + + Scenario: db check without --quiet flag should show informational messages + Given a WP install + + When I run `wp db check` + Then STDOUT should contain: + """ + wp_cli_test.wp_users + """ + And STDOUT should contain: + """ + Success: Database checked. + """ + + Scenario: db optimize without --quiet flag should show informational messages + Given a WP install + + When I run `wp db optimize` + Then STDOUT should contain: + """ + wp_cli_test.wp_users + """ + And STDOUT should contain: + """ + Success: Database optimized. + """ + + Scenario: db repair without --quiet flag should show informational messages + Given a WP install + + When I run `wp db repair` + Then STDOUT should contain: + """ + wp_cli_test.wp_users + """ + And STDOUT should contain: + """ + Success: Database repaired. + """ + + Scenario: db check can explicitly pass --silent to mysqlcheck + Given a WP install + + When I run `wp db check --silent` + Then STDOUT should not contain: + """ + wp_cli_test.wp_users + """ + And STDOUT should contain: + """ + Success: Database checked. + """ + + Scenario: db optimize can explicitly pass --silent to mysqlcheck + Given a WP install + + When I run `wp db optimize --silent` + Then STDOUT should not contain: + """ + wp_cli_test.wp_users + """ + And STDOUT should contain: + """ + Success: Database optimized. + """ + + Scenario: db repair can explicitly pass --silent to mysqlcheck + Given a WP install + + When I run `wp db repair --silent` + Then STDOUT should not contain: + """ + wp_cli_test.wp_users + """ + And STDOUT should contain: + """ + Success: Database repaired. + """ diff --git a/src/DB_Command.php b/src/DB_Command.php index 06781cee..222b4f6d 100644 --- a/src/DB_Command.php +++ b/src/DB_Command.php @@ -259,6 +259,12 @@ public function check( $_, $assoc_args ) { WP_CLI::debug( "Running shell command: {$command}", 'db' ); $assoc_args['check'] = true; + + // Pass --silent to mysqlcheck when in quiet mode. + if ( WP_CLI::get_config( 'quiet' ) ) { + $assoc_args['silent'] = true; + } + self::run( Utils\esc_cmd( $command, DB_NAME ), $assoc_args @@ -307,6 +313,12 @@ public function optimize( $_, $assoc_args ) { WP_CLI::debug( "Running shell command: {$command}", 'db' ); $assoc_args['optimize'] = true; + + // Pass --silent to mysqlcheck when in quiet mode. + if ( WP_CLI::get_config( 'quiet' ) ) { + $assoc_args['silent'] = true; + } + self::run( Utils\esc_cmd( $command, DB_NAME ), $assoc_args @@ -355,6 +367,12 @@ public function repair( $_, $assoc_args ) { WP_CLI::debug( "Running shell command: {$command}", 'db' ); $assoc_args['repair'] = true; + + // Pass --silent to mysqlcheck when in quiet mode. + if ( WP_CLI::get_config( 'quiet' ) ) { + $assoc_args['silent'] = true; + } + self::run( Utils\esc_cmd( $command, DB_NAME ), $assoc_args From 73aad752d1bba8cdee908be826d1f7b1497e244d Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 13 Jan 2026 10:18:53 +0100 Subject: [PATCH 3/4] Move tests --- features/db-check.feature | 19 +++++++ features/db-quiet.feature | 109 -------------------------------------- features/db.feature | 47 +++++++++++++++- 3 files changed, 65 insertions(+), 110 deletions(-) delete mode 100644 features/db-quiet.feature diff --git a/features/db-check.feature b/features/db-check.feature index aa5ce47b..7c105c82 100644 --- a/features/db-check.feature +++ b/features/db-check.feature @@ -13,6 +13,25 @@ Feature: Check the database Success: Database checked. """ + Scenario: db check with --quiet flag should only show errors + Given a WP install + + When I run `wp db check --quiet` + Then STDOUT should be empty + + Scenario: db check can explicitly pass --silent to mysqlcheck + Given a WP install + + When I run `wp db check --silent` + Then STDOUT should not contain: + """ + wp_cli_test.wp_users + """ + And STDOUT should contain: + """ + Success: Database checked. + """ + Scenario: Run db check with MySQL defaults to check the database Given a WP install diff --git a/features/db-quiet.feature b/features/db-quiet.feature deleted file mode 100644 index 03a8212a..00000000 --- a/features/db-quiet.feature +++ /dev/null @@ -1,109 +0,0 @@ -Feature: Quiet mode for database operations - - Scenario: db check with --quiet flag should only show errors - Given a WP install - - When I run `wp db check --quiet` - Then STDOUT should not contain: - """ - wp_cli_test.wp_users - """ - And STDOUT should be empty - - Scenario: db optimize with --quiet flag should only show errors - Given a WP install - - When I run `wp db optimize --quiet` - Then STDOUT should not contain: - """ - wp_cli_test.wp_users - """ - And STDOUT should be empty - - Scenario: db repair with --quiet flag should only show errors - Given a WP install - - When I run `wp db repair --quiet` - Then STDOUT should not contain: - """ - wp_cli_test.wp_users - """ - And STDOUT should be empty - - Scenario: db check without --quiet flag should show informational messages - Given a WP install - - When I run `wp db check` - Then STDOUT should contain: - """ - wp_cli_test.wp_users - """ - And STDOUT should contain: - """ - Success: Database checked. - """ - - Scenario: db optimize without --quiet flag should show informational messages - Given a WP install - - When I run `wp db optimize` - Then STDOUT should contain: - """ - wp_cli_test.wp_users - """ - And STDOUT should contain: - """ - Success: Database optimized. - """ - - Scenario: db repair without --quiet flag should show informational messages - Given a WP install - - When I run `wp db repair` - Then STDOUT should contain: - """ - wp_cli_test.wp_users - """ - And STDOUT should contain: - """ - Success: Database repaired. - """ - - Scenario: db check can explicitly pass --silent to mysqlcheck - Given a WP install - - When I run `wp db check --silent` - Then STDOUT should not contain: - """ - wp_cli_test.wp_users - """ - And STDOUT should contain: - """ - Success: Database checked. - """ - - Scenario: db optimize can explicitly pass --silent to mysqlcheck - Given a WP install - - When I run `wp db optimize --silent` - Then STDOUT should not contain: - """ - wp_cli_test.wp_users - """ - And STDOUT should contain: - """ - Success: Database optimized. - """ - - Scenario: db repair can explicitly pass --silent to mysqlcheck - Given a WP install - - When I run `wp db repair --silent` - Then STDOUT should not contain: - """ - wp_cli_test.wp_users - """ - And STDOUT should contain: - """ - Success: Database repaired. - """ diff --git a/features/db.feature b/features/db.feature index dbfdb4b0..0a2be953 100644 --- a/features/db.feature +++ b/features/db.feature @@ -185,6 +185,51 @@ Feature: Perform database operations """ And STDOUT should not be empty + Scenario: db optimize with --quiet flag should only show errors + Given a WP install + + When I run `wp db optimize --quiet` + Then STDOUT should not contain: + """ + error + """ + + + Scenario: db optimize can explicitly pass --silent to mysqlcheck + Given a WP install + + When I run `wp db optimize --silent` + Then STDOUT should not contain: + """ + wp_cli_test.wp_users + """ + And STDOUT should contain: + """ + Success: Database optimized. + """ + + Scenario: db repair with --quiet flag should only show errors + Given a WP install + + When I run `wp db repair --quiet` + Then STDOUT should not contain: + """ + error + """ + + Scenario: db repair can explicitly pass --silent to mysqlcheck + Given a WP install + + When I run `wp db repair --silent` + Then STDOUT should not contain: + """ + error + """ + And STDOUT should contain: + """ + Success: Database repaired. + """ + Scenario: DB Query Given a WP install @@ -334,7 +379,7 @@ Feature: Perform database operations """ Query succeeded. Rows affected: 1 """ - + When I run `wp db query "SELECT * FROM wp_users WHERE ID = 1"` Then STDOUT should not contain: """ From 1a36babaac120433d92eb5dbe3c0cbf1ef956141 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 13 Jan 2026 12:36:54 +0100 Subject: [PATCH 4/4] Update test --- features/db.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/db.feature b/features/db.feature index 0a2be953..1f44a6c5 100644 --- a/features/db.feature +++ b/features/db.feature @@ -201,7 +201,7 @@ Feature: Perform database operations When I run `wp db optimize --silent` Then STDOUT should not contain: """ - wp_cli_test.wp_users + error """ And STDOUT should contain: """