wp-cli / wp-cli

⚙️ WP-CLI framework

Home Page:https://wp-cli.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failing tests because of `mysqldump --skip-column-statistics` arg

swissspidy opened this issue · comments

The following test is currently failing on tests running MySQL 5.6:

# This throws a warning because of the password.
When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--dmemory_limit=50M -ddisable_functions=ini_set} eval '\WP_CLI\Utils\run_mysql_command("/usr/bin/env mysqldump --skip-column-statistics --no-tablespaces {DB_NAME}", [ "user" => "{DB_USER}", "pass" => "{DB_PASSWORD}", "host" => "{DB_HOST}" ], null, true);'`
Then the return code should be 0
And STDOUT should not be empty
And STDOUT should contain:
"""
CREATE TABLE
"""
And STDOUT should contain:
"""
{ONE_MB_OF_DATA}
"""

Example:

001 Scenario: Ensure that Utils\run_mysql_command() passes through without reading full DB into memory # features/utils.feature:108
      Then the return code should be 0                                                                 # features/utils.feature:161
        $ WP_CLI_PHP_ARGS='-dmemory_limit=50M -ddisable_functions=ini_set' wp eval '\WP_CLI\Utils\run_mysql_command("/usr/bin/env mysqldump --skip-column-statistics --no-tablespaces wp_cli_test", [ "user" => "wp_cli_test", "pass" => "password1", "host" => "127.0.0.1:3306" ], null, true);'
        
        PHP Warning:  ini_set() has been disabled for security reasons in php/WP_CLI/Runner.php on line 1992
        PHP Warning:  ini_set() has been disabled for security reasons in php/wp-settings-cli.php on line 52
        PHP Warning:  ini_set() has been disabled for security reasons in php/wp-settings-cli.php on line 53
        PHP Warning:  ini_set() has been disabled for security reasons in php/utils-wp.php on line 83
        PHP Warning:  ini_set() has been disabled for security reasons in php/WP_CLI/Runner.php on line 1381
        PHP Warning:  ini_set() has been disabled for security reasons in php/WP_CLI/Runner.php on line 19[92](https://github.com/wp-cli/wp-cli/actions/runs/7578297369/job/20640766485#step:11:93)
        mysqldump: unknown option '--skip-column-statistics'
        cwd: /tmp/wp-cli-test-run--65a9d8a3283118.67615607/
        run time: 0.269742012023[93](https://github.com/wp-cli/wp-cli/actions/runs/7578297369/job/20640766485#step:11:94)
        exit status: 2 (RuntimeException)

That's because the --skip-column-statistics arg was only introduced later.

Can we remove the arg for this test?

If not, can we only add it on supported MySQL versions?

In other places such as DB_Command.php we first check the result of mysqldump --help | grep 'column-statistics' to see whether the arg is supported. Not sure how best to do that in Behat though.