Skip to content

Commit cdb494e

Browse files
Copilotswissspidy
andcommitted
Remove unnecessary SQL mode check from wp db query command
This check was causing authentication failures when custom connection parameters (like --host) were passed, because get_current_sql_modes() ignored those parameters. The check is also unnecessary since wp db query doesn't use WPDB directly, and was inconsistently applied (skipped for STDIN). Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent a224115 commit cdb494e

File tree

2 files changed

+0
-32
lines changed

2 files changed

+0
-32
lines changed

features/db-query.feature

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -84,31 +84,4 @@ Feature: Query the database with WordPress' MySQL config
8484
When I try `wp db query --no-defaults --debug`
8585
Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysql|mariadb) --no-defaults --no-auto-rehash#
8686

87-
Scenario: SQL modes do not include any of the modes incompatible with WordPress
88-
Given a WP install
8987

90-
When I try `wp db query 'SELECT @@SESSION.sql_mode;' --debug`
91-
Then STDOUT should not contain:
92-
"""
93-
NO_ZERO_DATE
94-
"""
95-
And STDOUT should not contain:
96-
"""
97-
ONLY_FULL_GROUP_BY
98-
"""
99-
And STDOUT should not contain:
100-
"""
101-
STRICT_TRANS_TABLES
102-
"""
103-
And STDOUT should not contain:
104-
"""
105-
STRICT_ALL_TABLES
106-
"""
107-
And STDOUT should not contain:
108-
"""
109-
TRADITIONAL
110-
"""
111-
And STDOUT should not contain:
112-
"""
113-
ANSI
114-
"""

src/DB_Command.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,6 @@ public function query( $args, $assoc_args ) {
533533
$assoc_args['execute'] = $args[0];
534534
}
535535

536-
if ( isset( $assoc_args['execute'] ) ) {
537-
// Ensure that the SQL mode is compatible with WPDB.
538-
$assoc_args['execute'] = $this->get_sql_mode_query( $assoc_args ) . $assoc_args['execute'];
539-
}
540-
541536
$is_row_modifying_query = isset( $assoc_args['execute'] ) && preg_match( '/\b(UPDATE|DELETE|INSERT|REPLACE|LOAD DATA)\b/i', $assoc_args['execute'] );
542537

543538
if ( $is_row_modifying_query ) {

0 commit comments

Comments
 (0)