Skip to content
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

[HPOS CLI] Allow --re-migrate to be used even when --verbose is not set #44669

Merged
merged 4 commits into from Mar 4, 2024

Conversation

jorgeatorres
Copy link
Member

@jorgeatorres jorgeatorres commented Feb 15, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

Currently, while verifying order data via the CLI tool wp cot verify_cot_data, the --re-migrate flag (which attempts to sync the order again if verification fails) requires the use of --verbose too.

While this isn't necessarily problematic, it'd be best to support --re-migrate regardless of the --verbose flag to reduce confusion. This PR makes that possible and also allows the tool to display completion messages ("M orders were verified in N seconds") even when verbosity is enabled.

Closes #41248.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Make sure your site has a few test orders and note at least a few order IDs.
  2. Make sure HPOS is set as datastore and compatibility mode is disabled in WC > Settings > Advanced > Features.
  3. Run wp wc cot sync to sync orders.
  4. Run wp wc cot verify_cot_data and make sure no verification errors are indicated. This way we make sure we're starting at a "no verification errors" state.
    If there are, in fact, errores reported for any order, you should be able to address those manually by running wp hpos backfill <order_id> --from=posts --to=hpos.
  5. Run wp wc cot verify_cot_data --verbose and make sure the completion message appears ("Success: X orders were verified in Y seconds.")
  6. Manually introduce some differences between the post and HPOS records of a few orders. For example, try a few variations of the following commands:
    • wp post meta update <order id> some_random_meta_name 123
    • wp post meta update <anothe order id> _billing_first_name "Kip Stephen Thorne"
  7. Run wp wc cot verify_cot_data and confirm that the differences introduced above are reported as errors.
  8. Run wp wc cot verify_cot_data --re-migrate and confirm that no errores are reported. Note that we didn't have to use --verbose for it to work.

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Feb 15, 2024
Copy link
Contributor

github-actions bot commented Feb 15, 2024

Test Results Summary

Commit SHA: 19dc888

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 38s
E2E Tests34600503517m 29s

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.

@jorgeatorres jorgeatorres marked this pull request as ready for review February 17, 2024 02:19
@jorgeatorres jorgeatorres requested review from a team and vedanshujain and removed request for a team February 23, 2024 13:01
Copy link
Contributor

Hi @vedanshujain,

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:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Contributor

@vedanshujain vedanshujain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, added a small comment

if ( count( $errors_in_remigrate_batch ) > 0 ) {
$error_processing = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, when re-migration fails, perhaps we should still show a message that re-migration was attempted but was failed. wdyt? currently, based on messages it looks like re-migration was never attempted for failed cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a remigrate_failed => true line to the errors when that happens (see 19dc888). I believe this conveys the same without us having to split errors between failed and failed after remigration, but please let me know what you think.

Example:

Screenshot 2024-02-29 at 16 14 50

@jorgeatorres
Copy link
Member Author

Hey @vedanshujain! Thanks for the review. I've added a quick fix for what you mentioned. Let me know if that works.

@vedanshujain vedanshujain merged commit 0d11d07 into trunk Mar 4, 2024
36 checks passed
@vedanshujain vedanshujain deleted the fix/41248 branch March 4, 2024 11:30
@github-actions github-actions bot added this to the 8.8.0 milestone Mar 4, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Mar 4, 2024
thealexandrelara pushed a commit that referenced this pull request Mar 4, 2024
…ot set (#44669)

* Allow `—re-migrate` to work even when `—verbose` is not set

* Add changelog

* Docblock update

* Indicate that remigration was attempted in errors array
@alvarothomas alvarothomas added status: analysis complete Indicates if a PR has been analysed by Solaris needs: internal testing Indicates if the PR requires further testing conducted by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Mar 5, 2024
Konamiman pushed a commit that referenced this pull request Mar 13, 2024
…ot set (#44669)

* Allow `—re-migrate` to work even when `—verbose` is not set

* Add changelog

* Docblock update

* Indicate that remigration was attempted in errors array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: internal testing Indicates if the PR requires further testing conducted by Solaris plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CLI] HPOS sync tool ignores --remigrate unless --verbose is used
3 participants