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.
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-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.