Stop reordering most mysql arguments#221
Merged
schlessera merged 2 commits intowp-cli:masterfrom Jul 14, 2022
Merged
Conversation
schlessera
approved these changes
Jul 14, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 exportoutput had changed.The changed argument order can be observed by reading
--debugoutput.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 --debugWP-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
mysqldumpto output a single multi-row INSERT statement rather than an INSERT statement per row as the original command specified (with an--optarg followed by--skip-extended-insert).The Fix
This PR updates the argument sorting to explicitly sort a
forceargument 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
--forceargument in the middle of the arguments shows that the--forceargument is moved to the end without affecting the order of the other arguments.