@@ -252,7 +252,7 @@ public function check( $_, $assoc_args ) {
252252
253253 $ command = sprintf (
254254 '/usr/bin/env %s%s %s ' ,
255- $ this -> get_check_command (),
255+ Utils \get_sql_check_command (),
256256 $ this ->get_defaults_flag_string ( $ assoc_args ),
257257 '%s '
258258 );
@@ -300,7 +300,7 @@ public function check( $_, $assoc_args ) {
300300 public function optimize ( $ _ , $ assoc_args ) {
301301 $ command = sprintf (
302302 '/usr/bin/env %s%s %s ' ,
303- $ this -> get_check_command (),
303+ Utils \get_sql_check_command (),
304304 $ this ->get_defaults_flag_string ( $ assoc_args ),
305305 '%s '
306306 );
@@ -348,7 +348,7 @@ public function optimize( $_, $assoc_args ) {
348348 public function repair ( $ _ , $ assoc_args ) {
349349 $ command = sprintf (
350350 '/usr/bin/env %s%s %s ' ,
351- $ this -> get_check_command (),
351+ Utils \get_sql_check_command (),
352352 $ this ->get_defaults_flag_string ( $ assoc_args ),
353353 '%s '
354354 );
@@ -397,7 +397,11 @@ public function repair( $_, $assoc_args ) {
397397 */
398398 public function cli ( $ _ , $ assoc_args ) {
399399
400- $ command = sprintf ( '/usr/bin/env mysql%s --no-auto-rehash ' , $ this ->get_defaults_flag_string ( $ assoc_args ) );
400+ $ command = sprintf (
401+ '/usr/bin/env %s%s --no-auto-rehash ' ,
402+ $ this ->get_mysql_command (),
403+ $ this ->get_defaults_flag_string ( $ assoc_args )
404+ );
401405 WP_CLI ::debug ( "Running shell command: {$ command }" , 'db ' );
402406
403407 if ( ! isset ( $ assoc_args ['database ' ] ) ) {
@@ -496,7 +500,11 @@ public function cli( $_, $assoc_args ) {
496500 */
497501 public function query ( $ args , $ assoc_args ) {
498502
499- $ command = sprintf ( '/usr/bin/env mysql%s --no-auto-rehash ' , $ this ->get_defaults_flag_string ( $ assoc_args ) );
503+ $ command = sprintf (
504+ '/usr/bin/env %s%s --no-auto-rehash ' ,
505+ $ this ->get_mysql_command (),
506+ $ this ->get_defaults_flag_string ( $ assoc_args )
507+ );
500508 WP_CLI ::debug ( "Running shell command: {$ command }" , 'db ' );
501509
502510 $ assoc_args ['database ' ] = DB_NAME ;
@@ -642,7 +650,7 @@ public function export( $args, $assoc_args ) {
642650 $ assoc_args ['result-file ' ] = $ result_file ;
643651 }
644652
645- $ mysqldump_binary = Utils \force_env_on_nix_systems ( $ this -> get_dump_command () );
653+ $ mysqldump_binary = Utils \force_env_on_nix_systems ( Utils \get_sql_dump_command () );
646654
647655 $ support_column_statistics = exec ( $ mysqldump_binary . ' --help | grep "column-statistics" ' );
648656
@@ -732,7 +740,8 @@ private function get_posts_table_charset( $assoc_args ) {
732740
733741 list ( $ stdout , $ stderr , $ exit_code ) = self ::run (
734742 sprintf (
735- '/usr/bin/env mysql%s --no-auto-rehash --batch --skip-column-names ' ,
743+ '%s%s --no-auto-rehash --batch --skip-column-names ' ,
744+ $ this ->get_mysql_command (),
736745 $ this ->get_defaults_flag_string ( $ assoc_args )
737746 ),
738747 [ 'execute ' => $ query ],
@@ -819,7 +828,11 @@ public function import( $args, $assoc_args ) {
819828 $ result_file = 'STDIN ' ;
820829 }
821830
822- $ command = sprintf ( '/usr/bin/env mysql%s --no-auto-rehash ' , $ this ->get_defaults_flag_string ( $ assoc_args ) );
831+ $ command = sprintf (
832+ '/usr/bin/env %s%s --no-auto-rehash ' ,
833+ $ this ->get_mysql_command (),
834+ $ this ->get_defaults_flag_string ( $ assoc_args )
835+ );
823836 WP_CLI ::debug ( "Running shell command: {$ command }" , 'db ' );
824837 WP_CLI ::debug ( 'Associative arguments: ' . json_encode ( $ assoc_args ), 'db ' );
825838
@@ -1752,7 +1765,8 @@ protected function run_query( $query, $assoc_args = [] ) {
17521765
17531766 self ::run (
17541767 sprintf (
1755- '/usr/bin/env mysql%s --no-auto-rehash ' ,
1768+ '%s%s --no-auto-rehash ' ,
1769+ $ this ->get_mysql_command (),
17561770 $ this ->get_defaults_flag_string ( $ assoc_args )
17571771 ),
17581772 array_merge ( [ 'execute ' => $ query ], $ mysql_args )
@@ -2152,7 +2166,8 @@ protected function get_current_sql_modes( $assoc_args ) {
21522166
21532167 list ( $ stdout , $ stderr , $ exit_code ) = self ::run (
21542168 sprintf (
2155- '/usr/bin/env mysql%s --no-auto-rehash --batch --skip-column-names ' ,
2169+ '%s%s --no-auto-rehash --batch --skip-column-names ' ,
2170+ $ this ->get_mysql_command (),
21562171 $ this ->get_defaults_flag_string ( $ assoc_args )
21572172 ),
21582173 array_merge ( $ args , [ 'execute ' => 'SELECT @@SESSION.sql_mode ' ] ),
@@ -2185,20 +2200,11 @@ protected function get_current_sql_modes( $assoc_args ) {
21852200 }
21862201
21872202 /**
2188- * Returns the correct `check ` command based on the detected database type.
2203+ * Returns the correct `mysql ` command based on the detected database type.
21892204 *
21902205 * @return string The appropriate check command.
21912206 */
2192- private function get_check_command () {
2193- return ( strpos ( Utils \get_mysql_version (), 'MariaDB ' ) !== false ) ? 'mariadb-check ' : 'mysqlcheck ' ;
2194- }
2195-
2196- /**
2197- * Returns the correct `dump` command based on the detected database type.
2198- *
2199- * @return string The appropriate dump command.
2200- */
2201- private function get_dump_command () {
2202- return ( strpos ( Utils \get_mysql_version (), 'MariaDB ' ) !== false ) ? 'mariadb-dump ' : 'mysqldump ' ;
2207+ private function get_mysql_command () {
2208+ return 'mariadb ' === Utils \get_db_type () ? 'mariadb ' : 'mysql ' ;
22032209 }
22042210}
0 commit comments