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/2] 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/2] 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