diff --git a/src/DB_Command.php b/src/DB_Command.php index 984a1d60..057b943c 100644 --- a/src/DB_Command.php +++ b/src/DB_Command.php @@ -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' ); @@ -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' ); @@ -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 ], @@ -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' ); @@ -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 ) @@ -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' ] ), @@ -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'; - } }