config-command
config-command copied to clipboard
DB-Check fails if Database requires SSL
Bug Report
- [x] Yes, I reviewed the contribution guidelines.
- [x] Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
Executing any config-command, that checks the database, e.g. wp config create
will result in the following error, if the database requires SSL:
ERROR 9002 (28000): SSL connection is required. Please specify SSL options and retry.
Even if you specify:
--extra-php <<PHP
define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL);
PHP
...because the check is not using PHP, but rather:
// Check DB connection.
if ( ! Utils\get_flag_value( $assoc_args, 'skip-check' ) ) {
Utils\run_mysql_command( '/usr/bin/env mysql --no-defaults', $mysql_db_connection_args );
}
(where mysql_db_connection_args
is hardcoded)
and there is currently no way to specify/inject an addition parameter like --ssl
!
Describe how other contributors can replicate this bug
Create a MySQL-DB that requires SSL (for Azure-MySQL there is button "Enforce SSL connection")
And then try wp config create
with valid credentials.
Describe what you would expect as the correct outcome Working MySQL-Connection.
Let us know what environment you are running this on environment independent.
Provide a possible solution
Either respect the addition PHP define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL);
or provide a parameter to enable SSL!
wp db export
seems to have such an option: https://github.com/wp-cli/db-command/issues/126#issuecomment-692876201
Also an issue for Digital Ocean's hosted MySQL service. I'd love to see this implemented as well.
Open to reviewing a pull request if someone would like to create one. Here is some guidance on our pull request best practices.