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
Address possible metadata duplication in 8.1 (backport) #40148
Conversation
Test Results SummaryCommit SHA: 57d08d7
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. |
|
||
if ( $object instanceof WC_Abstract_Order && $this->should_backfill_post_record() ) { | ||
$delete_meta = $this->data_store_meta->delete_meta( $object, $meta ); | ||
$changes_applied = $this->after_meta_change( $object, $meta ); |
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.
I'm not sure it's essential, but should we do anything if this returns false? Atm I don't believe we do anything with $changes_applied
.
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.
yeah, this should be included, adding a small commit for this.
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.
I think we're good, so provisionally approving (did leave one question, though).
Seems like PHP 7.4 tests with nightly are failing because of something in the build process. I'd recommend not fixing them here as this PR targets the release branch. |
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.
LGTM, cross-checked with #40129.
Submission Review Guidelines:
Changes proposed in this Pull Request:
This PR applies a subset of the changes from #40129, which -among other things-, prevent duplication of metadata when using the
save_meta_data()
order method, which is common with 3rd party code (including popular plugins such as WC Subscriptions).How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Make sure both HPOS and sync are enabled in WooCommerce > Settings > Advanced > Features.
Run the following PHP snippet via WP-CLI (for example):
Take note of the ID that gets printed to the screen.
Make sure that metadata
this_gets_duplicated
appears only once in the output of the following WP-CLI commands:wp db query "SELECT * FROM $(wp db prefix)wc_orders_meta WHERE order_id = ORDER_ID"
wp post meta list ORDER_ID
Replace
ORDER_ID
with the ID from step 2.In 8.1 (without this fix), you'll see that steps 3 shows you the metadata duplication.
Changelog entry
Significance
Type
Message
Comment