-
Notifications
You must be signed in to change notification settings - Fork 26
Fix MariaDB 11.4+ warnings with --no-defaults flag #297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5399e7d
2230ea0
30a9efa
aef1158
aa5f61b
3be0a6e
df5dbba
6adaead
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -834,7 +834,8 @@ public function __construct() { | |
| if ( getenv( 'WP_CLI_TEST_DBTYPE' ) ) { | ||
| $this->variables['DB_TYPE'] = getenv( 'WP_CLI_TEST_DBTYPE' ); | ||
| } else { | ||
| $this->variables['DB_TYPE'] = 'mysql'; | ||
| // Auto-detect database type if not explicitly set | ||
| $this->variables['DB_TYPE'] = Utils\get_db_type(); | ||
| } | ||
|
|
||
| if ( getenv( 'MYSQL_TCP_PORT' ) ) { | ||
|
|
@@ -1202,8 +1203,9 @@ public function create_db(): void { | |
| return; | ||
| } | ||
|
|
||
| $dbname = self::$db_settings['dbname']; | ||
| self::run_sql( self::$mysql_binary . ' --no-defaults', [ 'execute' => "CREATE DATABASE IF NOT EXISTS $dbname" ] ); | ||
| $dbname = self::$db_settings['dbname']; | ||
| $ssl_flag = 'mariadb' === self::$db_type ? ' --ssl-verify-server-cert' : ''; | ||
|
||
| self::run_sql( self::$mysql_binary . ' --no-defaults' . $ssl_flag, [ 'execute' => "CREATE DATABASE IF NOT EXISTS $dbname" ] ); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1214,8 +1216,9 @@ public function test_connection(): void { | |
| return; | ||
| } | ||
|
|
||
| $ssl_flag = 'mariadb' === self::$db_type ? ' --ssl-verify-server-cert' : ''; | ||
| $sql_result = self::run_sql( | ||
| self::$mysql_binary . ' --no-defaults', | ||
| self::$mysql_binary . ' --no-defaults' . $ssl_flag, | ||
| [ | ||
| 'execute' => 'SELECT 1', | ||
| 'send_to_shell' => false, | ||
|
|
@@ -1241,8 +1244,9 @@ public function drop_db(): void { | |
| if ( 'sqlite' === self::$db_type ) { | ||
| return; | ||
| } | ||
| $dbname = self::$db_settings['dbname']; | ||
| self::run_sql( self::$mysql_binary . ' --no-defaults', [ 'execute' => "DROP DATABASE IF EXISTS $dbname" ] ); | ||
| $dbname = self::$db_settings['dbname']; | ||
| $ssl_flag = 'mariadb' === self::$db_type ? ' --ssl-verify-server-cert' : ''; | ||
| self::run_sql( self::$mysql_binary . ' --no-defaults' . $ssl_flag, [ 'execute' => "DROP DATABASE IF EXISTS $dbname" ] ); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1479,7 +1483,8 @@ public function install_wp( $subdir = '', $version = '' ): void { | |
| if ( 'sqlite' === self::$db_type ) { | ||
| copy( "{$install_cache_path}.sqlite", "$run_dir/wp-content/database/.ht.sqlite" ); | ||
| } else { | ||
| self::run_sql( self::$mysql_binary . ' --no-defaults', [ 'execute' => "source {$install_cache_path}.sql" ], true /*add_database*/ ); | ||
| $ssl_flag = 'mariadb' === self::$db_type ? ' --ssl-verify-server-cert' : ''; | ||
| self::run_sql( self::$mysql_binary . ' --no-defaults' . $ssl_flag, [ 'execute' => "source {$install_cache_path}.sql" ], true /*add_database*/ ); | ||
| } | ||
| } else { | ||
| $this->proc( 'wp core install', $install_args, $subdir )->run_check(); | ||
|
|
@@ -1492,7 +1497,8 @@ public function install_wp( $subdir = '', $version = '' ): void { | |
| $mysqldump_binary = Utils\get_sql_dump_command(); | ||
| $mysqldump_binary = Utils\force_env_on_nix_systems( $mysqldump_binary ); | ||
| $support_column_statistics = exec( "{$mysqldump_binary} --help | grep 'column-statistics'" ); | ||
| $command = "{$mysqldump_binary} --no-defaults --no-tablespaces"; | ||
| $ssl_flag = 'mariadb' === self::$db_type ? ' --ssl-verify-server-cert' : ''; | ||
| $command = "{$mysqldump_binary} --no-defaults{$ssl_flag} --no-tablespaces"; | ||
| if ( $support_column_statistics ) { | ||
| $command .= ' --skip-column-statistics'; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code calls
Utils\get_db_type()from theWP_CLI\Utilsnamespace, but it's unclear if this function exists in the wp-cli package (specified as version ^2.12 in composer.json). If this function doesn't exist yet, this change will cause a fatal error when the constructor runs. Please verify that:get_db_type_and_version()function from utils/behat-tags.php)