Skip to content

Commit b2a51db

Browse files
authored
Merge pull request #295 from wp-cli/fix-290
2 parents cf0dba1 + 4652005 commit b2a51db

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/DB_Command.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -526,18 +526,17 @@ public function query( $args, $assoc_args ) {
526526
}
527527

528528
WP_CLI::debug( 'Associative arguments: ' . json_encode( $assoc_args ), 'db' );
529-
list( $stdout, $stderr, $exit_code ) = self::run( $command, $assoc_args, false );
530-
531-
if ( $exit_code ) {
532-
WP_CLI::error( "Query failed: {$stderr}" );
533-
}
534529

535530
if ( $is_row_modifying_query ) {
536-
$output_lines = explode( "\n", trim( $stdout ) );
537-
$affected_rows = (int) trim( end( $output_lines ) );
531+
list( $stdout, $stderr, $exit_code ) = self::run( $command, $assoc_args, false );
532+
$output_lines = explode( "\n", trim( $stdout ) );
533+
$affected_rows = (int) trim( end( $output_lines ) );
534+
if ( $exit_code ) {
535+
WP_CLI::error( "Query failed: {$stderr}" );
536+
}
538537
WP_CLI::success( "Query succeeded. Rows affected: {$affected_rows}" );
539-
} elseif ( ! empty( $stdout ) ) {
540-
WP_CLI::line( $stdout );
538+
} else {
539+
self::run( $command, $assoc_args );
541540
}
542541
}
543542

0 commit comments

Comments
 (0)