diff --git a/features/db-import.feature b/features/db-import.feature index 8438d06b..d1ba3348 100644 --- a/features/db-import.feature +++ b/features/db-import.feature @@ -155,13 +155,13 @@ Feature: Import a WordPress database Then the wp_cli_test.sql file should exist When I try `wp db import --defaults --debug` - Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysql|mariadb) --no-auto-rehash# + Then STDERR should match #Debug \(db\): Running shell command: /([^/]+/)+(mysql|mariadb) --no-auto-rehash# When I try `wp db import --debug` - Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysql|mariadb) --no-defaults --no-auto-rehash# + Then STDERR should match #Debug \(db\): Running shell command: /([^/]+/)+(mysql|mariadb) --no-defaults --no-auto-rehash# When I try `wp db import --no-defaults --debug` - Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysql|mariadb) --no-defaults --no-auto-rehash# + Then STDERR should match #Debug \(db\): Running shell command: /([^/]+/)+(mysql|mariadb) --no-defaults --no-auto-rehash# @require-mysql-or-mariadb Scenario: Import db that has emoji in post diff --git a/features/db-query.feature b/features/db-query.feature index 48a50af5..07b5a262 100644 --- a/features/db-query.feature +++ b/features/db-query.feature @@ -83,13 +83,13 @@ Feature: Query the database with WordPress' MySQL config Given a WP install When I try `wp db query --defaults --debug` - Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysql|mariadb) --no-auto-rehash# + Then STDERR should match #Debug \(db\): Running shell command: /([^/]+/)+(mysql|mariadb) --no-auto-rehash# When I try `wp db query --debug` - Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysql|mariadb) --no-defaults --no-auto-rehash# + Then STDERR should match #Debug \(db\): Running shell command: /([^/]+/)+(mysql|mariadb) --no-defaults --no-auto-rehash# When I try `wp db query --no-defaults --debug` - Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysql|mariadb) --no-defaults --no-auto-rehash# + Then STDERR should match #Debug \(db\): Running shell command: /([^/]+/)+(mysql|mariadb) --no-defaults --no-auto-rehash# Scenario: SQL modes do not include any of the modes incompatible with WordPress Given a WP install 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'; - } }