Skip to content

Commit e7efa7d

Browse files
authored
Merge pull request #178 from wp-cli/fix/173-db-cli-hangs
Use MySQL binary in interactive mode for `db cli` command
2 parents ad47e9a + 4821afd commit e7efa7d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/DB_Command.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public function cli( $_, $assoc_args ) {
367367
}
368368

369369
WP_CLI::debug( 'Associative arguments: ' . json_encode( $assoc_args ), 'db' );
370-
self::run( $command, $assoc_args );
370+
self::run( $command, $assoc_args, null, true );
371371
}
372372

373373
/**
@@ -1480,6 +1480,9 @@ protected function run_query( $query, $assoc_args = [] ) {
14801480
* use.
14811481
* @param bool $send_to_shell Optional. Whether to send STDOUT and STDERR
14821482
* immediately to the shell. Defaults to true.
1483+
* @param bool $interactive Optional. Whether MySQL is meant to be
1484+
* executed as an interactive process. Defaults
1485+
* to false.
14831486
*
14841487
* @return array {
14851488
* Associative array containing STDOUT and STDERR output.
@@ -1489,7 +1492,7 @@ protected function run_query( $query, $assoc_args = [] ) {
14891492
* @type int $exit_code Exit code of the process.
14901493
* }
14911494
*/
1492-
private static function run( $cmd, $assoc_args = [], $send_to_shell = true ) {
1495+
private static function run( $cmd, $assoc_args = [], $send_to_shell = true, $interactive = false ) {
14931496
$required = [
14941497
'host' => DB_HOST,
14951498
'user' => DB_USER,
@@ -1513,7 +1516,7 @@ private static function run( $cmd, $assoc_args = [], $send_to_shell = true ) {
15131516

15141517
$final_args = array_merge( $assoc_args, $required );
15151518

1516-
return Utils\run_mysql_command( $cmd, $final_args, null, $send_to_shell );
1519+
return Utils\run_mysql_command( $cmd, $final_args, null, $send_to_shell, $interactive );
15171520
}
15181521

15191522
/**

0 commit comments

Comments
 (0)