Skip to content
Open
Changes from all commits
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
27 changes: 9 additions & 18 deletions src/DB_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ public function cli( $_, $assoc_args ) {
}

$command = sprintf(
'/usr/bin/env %s%s --no-auto-rehash',
$this->get_mysql_command(),
'%s%s --no-auto-rehash',
Utils\get_mysql_binary_path(),
$this->get_defaults_flag_string( $assoc_args )
);
WP_CLI::debug( "Running shell command: {$command}", 'db' );
Expand Down Expand Up @@ -593,8 +593,8 @@ public function query( $args, $assoc_args ) {
}

$command = sprintf(
'/usr/bin/env %s%s --no-auto-rehash',
$this->get_mysql_command(),
'%s%s --no-auto-rehash',
Utils\get_mysql_binary_path(),
$this->get_defaults_flag_string( $assoc_args )
);
WP_CLI::debug( "Running shell command: {$command}", 'db' );
Expand Down Expand Up @@ -837,7 +837,7 @@ private function get_posts_table_charset( $assoc_args ) {
list( $stdout, $stderr, $exit_code ) = self::run(
sprintf(
'%s%s --no-auto-rehash --batch --skip-column-names',
$this->get_mysql_command(),
Utils\get_mysql_binary_path(),
$this->get_defaults_flag_string( $assoc_args )
),
[ 'execute' => $query ],
Expand Down Expand Up @@ -945,8 +945,8 @@ public function import( $args, $assoc_args ) {
}

$command = sprintf(
'/usr/bin/env %s%s --no-auto-rehash',
$this->get_mysql_command(),
'%s%s --no-auto-rehash',
Utils\get_mysql_binary_path(),
$this->get_defaults_flag_string( $assoc_args )
);
WP_CLI::debug( "Running shell command: {$command}", 'db' );
Expand Down Expand Up @@ -1939,7 +1939,7 @@ protected function run_query( $query, $assoc_args = [] ) {
self::run(
sprintf(
'%s%s --no-auto-rehash',
$this->get_mysql_command(),
Utils\get_mysql_binary_path(),
$this->get_defaults_flag_string( $assoc_args )
),
array_merge( [ 'execute' => $query ], $mysql_args )
Expand Down Expand Up @@ -2337,7 +2337,7 @@ protected function get_current_sql_modes( $assoc_args ) {
list( $stdout, $stderr, $exit_code ) = self::run(
sprintf(
'%s%s --no-auto-rehash --batch --skip-column-names',
$this->get_mysql_command(),
Utils\get_mysql_binary_path(),
$this->get_defaults_flag_string( $assoc_args )
),
array_merge( $args, [ 'execute' => 'SELECT @@SESSION.sql_mode' ] ),
Expand Down Expand Up @@ -2365,13 +2365,4 @@ protected function get_current_sql_modes( $assoc_args ) {

return $modes;
}

/**
* Returns the correct `mysql` command based on the detected database type.
*
* @return string The appropriate check command.
*/
private function get_mysql_command() {
return 'mariadb' === Utils\get_db_type() ? 'mariadb' : 'mysql';
}
}
Loading