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
Add wc hpos backfill
tool to backfill from/to either datastore
#44281
Conversation
Test Results SummaryCommit SHA: 3520f6d
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
c442d48
to
e3ad0eb
Compare
e3ad0eb
to
2dc815b
Compare
6576bc9
to
1afddff
Compare
Hi @Konamiman, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
plugins/woocommerce/src/Database/Migrations/CustomOrderTable/CLIRunner.php
Outdated
Show resolved
Hide resolved
* <id> | ||
* :The ID of the order. | ||
* | ||
* [--from=<hpos|posts>] |
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.
To be coherent with how multiple choice arguments are usually specified in the help of command line tools it could be:
--from={hpos|posts}
(angle brackets usually indicate non-literal values that need to be replaced, like in <order id>
)
And the same with --to
.
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 actually got me thinking what the "correct" format should be. I agree with you that the braces seem to better indicate the options, but apparently WP-CLI expects arguments in a specific format (https://make.wordpress.org/cli/handbook/references/documentation-standards/#command-parameter-description) and so I changed the documentation to match that. This actually allows WP-CLI to validate args before the command runs.
I also made the --from
and --to
arguments mandatory with no default, to make things more explicit and prevent accidental overwriting of orders.
Looks good, I just added a couple of comments regarding the arguments syntax used in the command help. |
Hey @Konamiman! I've made some changes based on your feedback. Please take another look at your leisure! Thanks for the review! |
Submission Review Guidelines:
Changes proposed in this Pull Request:
This PR adds a new CLI tool
wp hpos backfill
that can be used to backfill orders from either the HPOS or CPT datastore, regardless of what the current datastore is.This can be used to resolve situations where a given order has correct data in either table but the merchant can't change datastores or the sync process would overwrite other orders.
Closes #41909.
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
<meta_key>
) and value and clicking "Add Custom Field" or saving the order.wp post meta list <order_id>
and confirming the list doesn't include this new meta / is empty.wp wc hpos backfill <order_id> --from=hpos --to=posts
.wp post meta list <order_id>
and confirm that now all the order metadata appears, including the metadata you manually added.wp post meta update <order_id> <meta_key> <any_other_meta_value>
.wp wc hpos backfill <order_id> --from=posts --to=hpos
to backfill from posts to HPOS.Changelog entry
Significance
Type
Message
Comment