Stop reordering most mysql arguments #221
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WP-CLI v2.6.0 is breaking mysql argument order, apparently due to how arguments are sorted here.
On WordPress.com, with WP-CLI v2.6.0, we discovered this due to backups that were failing because
wp db export
output had changed.The changed argument order can be observed by reading
--debug
output.WP-CLI v2.5.0
For the command:
wp --path=/srv/htdocs/__wp__/ --skip-plugins --skip-themes db export - --tables=wp_commentmeta --opt --compact --quick --single-transaction --complete-insert --skip-extended-insert --max-allowed-packet=100M --debug
WP-CLI v2.5.0 shows the following, where the argument order in the final command generally follows the associative argument order.
WP-CLI v2.6.0
In contrast, WP-CLI v2.6.0 show the following, where the argument order in the final command does not reflect the associative argument order:
In this specific case, the difference in argument order causes
mysqldump
to output a single multi-row INSERT statement rather than an INSERT statement per row as the original command specified (with an--opt
arg followed by--skip-extended-insert
).The Fix
This PR updates the argument sorting to explicitly sort a
force
argument to the end while treating all other arguments as equal so their order, relative to one another, does not change. With this fix, the debug output shows the final command reflects the associate argument order:In addition, testing this fix with a
--force
argument in the middle of the arguments shows that the--force
argument is moved to the end without affecting the order of the other arguments.