@@ -398,8 +398,8 @@ public function repair( $_, $assoc_args ) {
398398 public function cli ( $ _ , $ assoc_args ) {
399399
400400 $ command = sprintf (
401- '/usr/bin/env %s%s --no-auto-rehash ' ,
402- $ this -> get_mysql_command (),
401+ '%s%s --no-auto-rehash ' ,
402+ Utils \get_mysql_binary_path (),
403403 $ this ->get_defaults_flag_string ( $ assoc_args )
404404 );
405405 WP_CLI ::debug ( "Running shell command: {$ command }" , 'db ' );
@@ -501,8 +501,8 @@ public function cli( $_, $assoc_args ) {
501501 public function query ( $ args , $ assoc_args ) {
502502
503503 $ command = sprintf (
504- '/usr/bin/env %s%s --no-auto-rehash ' ,
505- $ this -> get_mysql_command (),
504+ '%s%s --no-auto-rehash ' ,
505+ Utils \get_mysql_binary_path (),
506506 $ this ->get_defaults_flag_string ( $ assoc_args )
507507 );
508508 WP_CLI ::debug ( "Running shell command: {$ command }" , 'db ' );
@@ -740,8 +740,8 @@ private function get_posts_table_charset( $assoc_args ) {
740740
741741 list ( $ stdout , $ stderr , $ exit_code ) = self ::run (
742742 sprintf (
743- '/usr/bin/env %s%s --no-auto-rehash --batch --skip-column-names ' ,
744- $ this -> get_mysql_command (),
743+ '%s%s --no-auto-rehash --batch --skip-column-names ' ,
744+ Utils \get_mysql_binary_path (),
745745 $ this ->get_defaults_flag_string ( $ assoc_args )
746746 ),
747747 [ 'execute ' => $ query ],
@@ -829,8 +829,8 @@ public function import( $args, $assoc_args ) {
829829 }
830830
831831 $ command = sprintf (
832- '/usr/bin/env %s%s --no-auto-rehash ' ,
833- $ this -> get_mysql_command (),
832+ '%s%s --no-auto-rehash ' ,
833+ Utils \get_mysql_binary_path (),
834834 $ this ->get_defaults_flag_string ( $ assoc_args )
835835 );
836836 WP_CLI ::debug ( "Running shell command: {$ command }" , 'db ' );
@@ -1765,8 +1765,8 @@ protected function run_query( $query, $assoc_args = [] ) {
17651765
17661766 self ::run (
17671767 sprintf (
1768- '/usr/bin/env %s%s --no-auto-rehash ' ,
1769- $ this -> get_mysql_command (),
1768+ '%s%s --no-auto-rehash ' ,
1769+ Utils \get_mysql_binary_path (),
17701770 $ this ->get_defaults_flag_string ( $ assoc_args )
17711771 ),
17721772 array_merge ( [ 'execute ' => $ query ], $ mysql_args )
@@ -2166,7 +2166,7 @@ protected function get_current_sql_modes( $assoc_args ) {
21662166
21672167 list ( $ stdout , $ stderr , $ exit_code ) = self ::run (
21682168 sprintf (
2169- '/usr/bin/env %s%s --no-auto-rehash --batch --skip-column-names ' ,
2169+ '%s%s --no-auto-rehash --batch --skip-column-names ' ,
21702170 $ this ->get_mysql_command (),
21712171 $ this ->get_defaults_flag_string ( $ assoc_args )
21722172 ),
@@ -2199,22 +2199,13 @@ protected function get_current_sql_modes( $assoc_args ) {
21992199 return $ modes ;
22002200 }
22012201
2202- /**
2203- * Returns the correct `mysql` command based on the detected database type.
2204- *
2205- * @return string The appropriate check command.
2206- */
2207- private function get_mysql_command () {
2208- return ( strpos ( Utils \get_mysql_version (), 'MariaDB ' ) !== false ) ? 'mariadb ' : 'mysql ' ;
2209- }
2210-
22112202 /**
22122203 * Returns the correct `check` command based on the detected database type.
22132204 *
22142205 * @return string The appropriate check command.
22152206 */
22162207 private function get_check_command () {
2217- return ( strpos ( Utils \get_mysql_version (), ' MariaDB ' ) !== false ) ? 'mariadb-check ' : 'mysqlcheck ' ;
2208+ return ' mariadb ' === Utils \get_db_type ( ) ? 'mariadb-check ' : 'mysqlcheck ' ;
22182209 }
22192210
22202211 /**
@@ -2223,6 +2214,6 @@ private function get_check_command() {
22232214 * @return string The appropriate dump command.
22242215 */
22252216 private function get_dump_command () {
2226- return ( strpos ( Utils \get_mysql_version (), ' MariaDB ' ) !== false ) ? 'mariadb-dump ' : 'mysqldump ' ;
2217+ return ' mariadb ' === Utils \get_db_type ( ) ? 'mariadb-dump ' : 'mysqldump ' ;
22272218 }
22282219}
0 commit comments