Skip to content
Merged
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
Next Next commit
Remove errant whitespace
  • Loading branch information
swissspidy committed Mar 6, 2025
commit 0e843081043d179d781fb581bc4f8bc21507f5a3
10 changes: 5 additions & 5 deletions src/DB_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,11 @@ public function query( $args, $assoc_args ) {
$command = sprintf( '/usr/bin/env mysql%s --no-auto-rehash', $this->get_defaults_flag_string( $assoc_args ) );
WP_CLI::debug( "Running shell command: {$command}", 'db' );
Comment thread
swissspidy marked this conversation as resolved.
Resolved
$assoc_args['database'] = DB_NAME;

if ( ! empty( $args ) ) {
$assoc_args['execute'] = $args[0];
}

if ( isset( $assoc_args['execute'] ) ) {
$assoc_args['execute'] = $this->get_sql_mode_query( $assoc_args ) . $assoc_args['execute'];
}
Expand All @@ -512,14 +512,14 @@ public function query( $args, $assoc_args ) {
// Append `SELECT ROW_COUNT()` to the query.
Comment thread
mrsdizzie marked this conversation as resolved.
Resolved
$assoc_args['execute'] .= '; SELECT ROW_COUNT();';
}

WP_CLI::debug( 'Associative arguments: ' . json_encode( $assoc_args ), 'db' );
Comment thread
swissspidy marked this conversation as resolved.
Resolved
list( $stdout, $stderr, $exit_code ) = self::run( $command, $assoc_args, false );

if ( $exit_code ) {
WP_CLI::error( "Query failed: {$stderr}" );
}

// For UPDATE/DELETE queries, parse the output to get the number of rows affected.
Comment thread
mrsdizzie marked this conversation as resolved.
Resolved
if ( isset( $assoc_args['execute'] ) && preg_match( '/\b(UPDATE|DELETE|INSERT)\b/i', $assoc_args['execute'] ) ) {
$output_lines = explode( "\n", trim( $stdout ) );
Expand Down