Skip to content

Commit 857c616

Browse files
Phpcs Updates
1 parent 99d44cb commit 857c616

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/DB_Command.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -495,32 +495,35 @@ public function cli( $_, $assoc_args ) {
495495
* +---------+-----------------------+
496496
*/
497497
public function query( $args, $assoc_args ) {
498+
498499
$command = sprintf( '/usr/bin/env mysql%s --no-auto-rehash', $this->get_defaults_flag_string( $assoc_args ) );
500+
WP_CLI::debug( "Running shell command: {$command}", 'db' );
499501
$assoc_args['database'] = DB_NAME;
500-
502+
501503
if ( ! empty( $args ) ) {
502504
$assoc_args['execute'] = $args[0];
503505
}
504-
506+
505507
if ( isset( $assoc_args['execute'] ) ) {
506508
$assoc_args['execute'] = $this->get_sql_mode_query( $assoc_args ) . $assoc_args['execute'];
507509
}
508-
509-
// Check if the query is an UPDATE or DELETE.
510+
511+
// Check if the query is an UPDATE or DELETE.
510512
if ( isset( $assoc_args['execute'] ) && preg_match( '/\b(UPDATE|DELETE)\b/i', $assoc_args['execute'] ) ) {
511513
// Append `SELECT ROW_COUNT()` to the query.
512514
$assoc_args['execute'] .= '; SELECT ROW_COUNT();';
513515
}
514-
515-
list( $stdout, $stderr, $exit_code ) = self::run( $command, $assoc_args, false );
516-
516+
517+
WP_CLI::debug( 'Associative arguments: ' . json_encode( $assoc_args ), 'db' );
518+
list( $stdout, $stderr, $exit_code ) = self::run( $command, $assoc_args, false );
519+
517520
if ( $exit_code ) {
518521
WP_CLI::error( "Query failed: {$stderr}" );
519522
}
520-
521-
// For UPDATE/DELETE queries, parse the output to get the number of rows affected.
523+
524+
// For UPDATE/DELETE queries, parse the output to get the number of rows affected.
522525
if ( isset( $assoc_args['execute'] ) && preg_match( '/\b(UPDATE|DELETE)\b/i', $assoc_args['execute'] ) ) {
523-
$output_lines = explode( "\n", trim( $stdout ) );
526+
$output_lines = explode( "\n", trim( $stdout ) );
524527
$affected_rows = (int) trim( end( $output_lines ) );
525528
WP_CLI::success( "Query succeeded. Rows affected: {$affected_rows}" );
526529
} else {

0 commit comments

Comments
 (0)