diff --git a/features/db-query.feature b/features/db-query.feature index 48a50af5..db185d06 100644 --- a/features/db-query.feature +++ b/features/db-query.feature @@ -91,31 +91,4 @@ Feature: Query the database with WordPress' MySQL config When I try `wp db query --no-defaults --debug` Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysql|mariadb) --no-defaults --no-auto-rehash# - Scenario: SQL modes do not include any of the modes incompatible with WordPress - Given a WP install - When I try `wp db query 'SELECT @@SESSION.sql_mode;' --debug` - Then STDOUT should not contain: - """ - NO_ZERO_DATE - """ - And STDOUT should not contain: - """ - ONLY_FULL_GROUP_BY - """ - And STDOUT should not contain: - """ - STRICT_TRANS_TABLES - """ - And STDOUT should not contain: - """ - STRICT_ALL_TABLES - """ - And STDOUT should not contain: - """ - TRADITIONAL - """ - And STDOUT should not contain: - """ - ANSI - """ diff --git a/src/DB_Command.php b/src/DB_Command.php index e0d7ad47..51e047e3 100644 --- a/src/DB_Command.php +++ b/src/DB_Command.php @@ -2301,9 +2301,12 @@ protected function get_sql_mode_query( $assoc_args, $modes = [] ) { protected function get_current_sql_modes( $assoc_args ) { static $modes = null; - // Make sure the provided arguments don't interfere with the expected - // output here. - $args = []; + // Pass through connection parameters like host, dbuser, dbpass + // but filter out other parameters that might interfere with the query output. + $args = array_merge( + self::get_dbuser_dbpass_args( $assoc_args ), + self::get_mysql_args( $assoc_args ) + ); if ( null === $modes ) { $modes = [];