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
Do not attempt to cache orders during order creation #37569
Conversation
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: |
Test Results SummaryCommit SHA: 817458a
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. |
This allows all the hooks when getting an order to be executed and we cache the correct object.
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!
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## trunk #37569 +/- ##
==========================================
- Coverage 51.7% 51.7% -0.0%
Complexity 17257 17257
==========================================
Files 429 429
Lines 79765 79765
==========================================
- Hits 41202 41200 -2
- Misses 38563 38565 +2
|
* Do not attempt to cache orders during order creation (#37569) * Prep for cherry pick 37569 --------- Co-authored-by: Vedanshu Jain <vedanshu.jain.2012@gmail.com> Co-authored-by: WooCommerce Bot <no-reply@woocommerce.com>
Submission Review Guidelines:
Changes proposed in this Pull Request:
As described in #37568, during an order's save various hooks are fired, and after most are executed, the orders cache attempts to cache the order.
Thing is, if during the execution of any of those hooks,
wc_get_order()
gets called on that same order ID, we end up in a situation where the cache first obtained and saved a specific order class (during thewc_get_order()
call) and thenWC_Abstract_Order::save()
overrides that with the genericWC_Order
instance that initiated the save.This PR attempts to fix this by preventing the cache logic in
WC_Abstract_Order::save()
from intervening when we're creating an order. During edits/updates, things should be safer, as we should already be working on an object of the correct type.Closes #37568.
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
trunk
, it printsWC_Order
.Automattic\WooCommerce\Admin\Overrides\Order
, which is the correct order type.