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

Add support to HPOS CLI tool for handling deleted orders #46970

Merged
merged 2 commits into from
May 14, 2024
Merged

Conversation

jorgeatorres
Copy link
Member

@jorgeatorres jorgeatorres commented Apr 26, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

Currently, when the cleanup tool is used, it'll attempt to compare the order from posts and also HPOS, and will fail when the order doesn't exist (on the HPOS side).
Given a prerequisite for using the cleanup tool is that HPOS is authoritative and sync is disabled, I believe it's safe to assume that those posts can be deleted.

This PR lets the cleanup tool remove meta for such posts and then delete the post itself if there's no corresponding order on the HPOS side.

Closes #45865 and #46592.

How to test the changes in this Pull Request:

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

  1. Make sure HPOS is enabled in WC > Settings > Advanced > Features and compatibility mode is disabled.
  2. Create a few test orders on your site. Take note of the ID for at least two of those orders.
  3. Sync orders by running wp wc hpos sync.
  4. Manually "delete" one of the orders from step 2 by running this command:
    wp db query "DELETE FROM $(wp db prefix)wc_orders WHERE id = <order_id>"
    
  5. Run wp wc hpos cleanup all to perform a cleanup and confirm the command runs successfully.
  6. Run wp post meta list <order_id> for both IDs from step 2 and confirm that:
    • For the ID removed in step 4, the command fails with a "Could not find the post with ID XXX" which means the post was truly removed.
    • For the other ID, the list is empty (meaning all metadata was cleaned up).

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 Apr 26, 2024
@jorgeatorres jorgeatorres marked this pull request as ready for review April 29, 2024 14:25
@jorgeatorres jorgeatorres requested review from a team and vedanshujain and removed request for a team April 29, 2024 14:25
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.

LGTM and tested well!

@vedanshujain vedanshujain merged commit f241b4d into trunk May 14, 2024
32 checks passed
@vedanshujain vedanshujain deleted the fix/45865 branch May 14, 2024 08:54
@github-actions github-actions bot added this to the 9.0.0 milestone May 14, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label May 14, 2024
@rodelgc rodelgc added needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels May 16, 2024
thealexandrelara pushed a commit that referenced this pull request Jul 18, 2024
* Add support for removed orders to cleanup tool

* Add changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. 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.

HPOS Legacy Data Cleanup not working with privacy deleted orders
3 participants