@@ -252,7 +252,7 @@ public function check( $_, $assoc_args ) {
252
252
253
253
$ command = sprintf (
254
254
'/usr/bin/env %s%s %s ' ,
255
- $ this -> get_check_command (),
255
+ Utils \get_sql_check_command (),
256
256
$ this ->get_defaults_flag_string ( $ assoc_args ),
257
257
'%s '
258
258
);
@@ -300,7 +300,7 @@ public function check( $_, $assoc_args ) {
300
300
public function optimize ( $ _ , $ assoc_args ) {
301
301
$ command = sprintf (
302
302
'/usr/bin/env %s%s %s ' ,
303
- $ this -> get_check_command (),
303
+ Utils \get_sql_check_command (),
304
304
$ this ->get_defaults_flag_string ( $ assoc_args ),
305
305
'%s '
306
306
);
@@ -348,7 +348,7 @@ public function optimize( $_, $assoc_args ) {
348
348
public function repair ( $ _ , $ assoc_args ) {
349
349
$ command = sprintf (
350
350
'/usr/bin/env %s%s %s ' ,
351
- $ this -> get_check_command (),
351
+ Utils \get_sql_check_command (),
352
352
$ this ->get_defaults_flag_string ( $ assoc_args ),
353
353
'%s '
354
354
);
@@ -397,7 +397,11 @@ public function repair( $_, $assoc_args ) {
397
397
*/
398
398
public function cli ( $ _ , $ assoc_args ) {
399
399
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
+ );
401
405
WP_CLI ::debug ( "Running shell command: {$ command }" , 'db ' );
402
406
403
407
if ( ! isset ( $ assoc_args ['database ' ] ) ) {
@@ -496,7 +500,11 @@ public function cli( $_, $assoc_args ) {
496
500
*/
497
501
public function query ( $ args , $ assoc_args ) {
498
502
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
+ );
500
508
WP_CLI ::debug ( "Running shell command: {$ command }" , 'db ' );
501
509
502
510
$ assoc_args ['database ' ] = DB_NAME ;
@@ -642,7 +650,7 @@ public function export( $args, $assoc_args ) {
642
650
$ assoc_args ['result-file ' ] = $ result_file ;
643
651
}
644
652
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 () );
646
654
647
655
$ support_column_statistics = exec ( $ mysqldump_binary . ' --help | grep "column-statistics" ' );
648
656
@@ -732,7 +740,8 @@ private function get_posts_table_charset( $assoc_args ) {
732
740
733
741
list ( $ stdout , $ stderr , $ exit_code ) = self ::run (
734
742
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 (),
736
745
$ this ->get_defaults_flag_string ( $ assoc_args )
737
746
),
738
747
[ 'execute ' => $ query ],
@@ -819,7 +828,11 @@ public function import( $args, $assoc_args ) {
819
828
$ result_file = 'STDIN ' ;
820
829
}
821
830
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
+ );
823
836
WP_CLI ::debug ( "Running shell command: {$ command }" , 'db ' );
824
837
WP_CLI ::debug ( 'Associative arguments: ' . json_encode ( $ assoc_args ), 'db ' );
825
838
@@ -1752,7 +1765,8 @@ protected function run_query( $query, $assoc_args = [] ) {
1752
1765
1753
1766
self ::run (
1754
1767
sprintf (
1755
- '/usr/bin/env mysql%s --no-auto-rehash ' ,
1768
+ '%s%s --no-auto-rehash ' ,
1769
+ $ this ->get_mysql_command (),
1756
1770
$ this ->get_defaults_flag_string ( $ assoc_args )
1757
1771
),
1758
1772
array_merge ( [ 'execute ' => $ query ], $ mysql_args )
@@ -2152,7 +2166,8 @@ protected function get_current_sql_modes( $assoc_args ) {
2152
2166
2153
2167
list ( $ stdout , $ stderr , $ exit_code ) = self ::run (
2154
2168
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 (),
2156
2171
$ this ->get_defaults_flag_string ( $ assoc_args )
2157
2172
),
2158
2173
array_merge ( $ args , [ 'execute ' => 'SELECT @@SESSION.sql_mode ' ] ),
@@ -2185,20 +2200,11 @@ protected function get_current_sql_modes( $assoc_args ) {
2185
2200
}
2186
2201
2187
2202
/**
2188
- * Returns the correct `check ` command based on the detected database type.
2203
+ * Returns the correct `mysql ` command based on the detected database type.
2189
2204
*
2190
2205
* @return string The appropriate check command.
2191
2206
*/
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 ' ;
2203
2209
}
2204
2210
}
0 commit comments