Skip to content

Try refactor wp db query --defaults handling, fix #237 #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix SQL mode discovery to preserve all MySQL connection arguments
- Replace empty foreach loop in get_current_sql_modes() with proper MySQL argument preservation using get_mysql_args()
- Add ssl-verify-server-cert to allowed MySQL options list
- Add test case to verify connection arguments are preserved during SQL mode discovery
- Fixes issue where connection flags like --ssl-verify-server-cert were lost during SQL mode discovery

Co-authored-by: lkraav <147228+lkraav@users.noreply.github.com>
  • Loading branch information
Copilot and lkraav committed Jun 26, 2025
commit 8d1e72fe022b596aed28be4ede31e3bc7b0101de
6 changes: 6 additions & 0 deletions features/db-query.feature
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ Feature: Query the database with WordPress' MySQL config
When I try `wp db query "SELECT 1;" --debug`
Then STDERR should match #Running shell command: /usr/bin/env (mysql|mariadb) --no-defaults --no-auto-rehash#

Scenario: SQL mode discovery preserves MySQL connection arguments
Given a WP install

When I try `wp db query "SELECT 1;" --host=testhost --port=3307 --debug`
Then STDERR should match #Final MySQL command: .* --host=testhost.*--port=3307#

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

Expand Down
10 changes: 3 additions & 7 deletions src/DB_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,7 @@ private static function get_mysql_args( $assoc_args ) {
'ssl-fips-mode',
'ssl-key',
'ssl-mode',
'ssl-verify-server-cert',
'syslog',
'table',
'tee',
Expand Down Expand Up @@ -2162,13 +2163,8 @@ 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 = [];
foreach ( [] as $arg ) {
if ( isset( $assoc_args[ $arg ] ) ) {
$args[ $arg ] = $assoc_args[ $arg ];
}
}
// output here. We need to preserve all valid MySQL arguments for connection.
$args = self::get_mysql_args( $assoc_args );

if ( null === $modes ) {
$modes = [];
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy