@@ -472,8 +472,8 @@ public function cli( $_, $assoc_args ) {
472472 }
473473
474474 $ command = sprintf (
475- '/usr/bin/env %s%s --no-auto-rehash ' ,
476- $ this -> get_mysql_command (),
475+ '%s%s --no-auto-rehash ' ,
476+ Utils \get_mysql_binary_path (),
477477 $ this ->get_defaults_flag_string ( $ assoc_args )
478478 );
479479 WP_CLI ::debug ( "Running shell command: {$ command }" , 'db ' );
@@ -593,8 +593,8 @@ public function query( $args, $assoc_args ) {
593593 }
594594
595595 $ command = sprintf (
596- '/usr/bin/env %s%s --no-auto-rehash ' ,
597- $ this -> get_mysql_command (),
596+ '%s%s --no-auto-rehash ' ,
597+ Utils \get_mysql_binary_path (),
598598 $ this ->get_defaults_flag_string ( $ assoc_args )
599599 );
600600 WP_CLI ::debug ( "Running shell command: {$ command }" , 'db ' );
@@ -837,7 +837,7 @@ private function get_posts_table_charset( $assoc_args ) {
837837 list ( $ stdout , $ stderr , $ exit_code ) = self ::run (
838838 sprintf (
839839 '%s%s --no-auto-rehash --batch --skip-column-names ' ,
840- $ this -> get_mysql_command (),
840+ Utils \get_mysql_binary_path (),
841841 $ this ->get_defaults_flag_string ( $ assoc_args )
842842 ),
843843 [ 'execute ' => $ query ],
@@ -945,8 +945,8 @@ public function import( $args, $assoc_args ) {
945945 }
946946
947947 $ command = sprintf (
948- '/usr/bin/env %s%s --no-auto-rehash ' ,
949- $ this -> get_mysql_command (),
948+ '%s%s --no-auto-rehash ' ,
949+ Utils \get_mysql_binary_path (),
950950 $ this ->get_defaults_flag_string ( $ assoc_args )
951951 );
952952 WP_CLI ::debug ( "Running shell command: {$ command }" , 'db ' );
@@ -1939,7 +1939,7 @@ protected function run_query( $query, $assoc_args = [] ) {
19391939 self ::run (
19401940 sprintf (
19411941 '%s%s --no-auto-rehash ' ,
1942- $ this -> get_mysql_command (),
1942+ Utils \get_mysql_binary_path (),
19431943 $ this ->get_defaults_flag_string ( $ assoc_args )
19441944 ),
19451945 array_merge ( [ 'execute ' => $ query ], $ mysql_args )
@@ -2337,7 +2337,7 @@ protected function get_current_sql_modes( $assoc_args ) {
23372337 list ( $ stdout , $ stderr , $ exit_code ) = self ::run (
23382338 sprintf (
23392339 '%s%s --no-auto-rehash --batch --skip-column-names ' ,
2340- $ this -> get_mysql_command (),
2340+ Utils \get_mysql_binary_path (),
23412341 $ this ->get_defaults_flag_string ( $ assoc_args )
23422342 ),
23432343 array_merge ( $ args , [ 'execute ' => 'SELECT @@SESSION.sql_mode ' ] ),
@@ -2365,17 +2365,4 @@ protected function get_current_sql_modes( $assoc_args ) {
23652365
23662366 return $ modes ;
23672367 }
2368-
2369- /**
2370- * Returns the correct `mysql` command based on the detected database type.
2371- *
2372- * Delegates to get_mysql_binary_path() which already probes for the MariaDB
2373- * binary and falls back to MySQL when not available.
2374- *
2375- * @return string The appropriate mysql command.
2376- */
2377- private function get_mysql_command () {
2378- $ path = Utils \get_mysql_binary_path ();
2379- return '' !== $ path ? basename ( $ path ) : 'mysql ' ;
2380- }
23812368}
0 commit comments