-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions and environment
- Magento version: 2.4.8-p1
- Anything else that would help a developer reproduce the bug
Given a system which has managed to create two orders for two different stores, with the same increment id in the sales_order table; the loadByIncrementId function in Order.php can return the wrong order. In my scenario, getLastRealOrder from app/code/Magento/Checkout/Model/Session.php would return the wrong order.
In my case, because there was no DB constraint preventing this data from existing, and parts of the magento code base assume that the incrementId will be unique, my system would attempt to update the wrong order at certain points.
I do not know how to replicate the scenario which caused by DB to get into such a state, but this does appear to be a small gap in the system. Assuming this gap is not for supporting an old behaviour of the system, it would make sense to either update the code base to close the possibility, or update the constraint check on the DB.
DB Constraint on the sales_order table:
Related Code:
loadByIncrementIdwith bad assumption thatincrement_idcan uniquely identify an order:public function loadByIncrementId($incrementId) - Example of this function being used which affected my system:
$this->_order->loadByIncrementId($orderId);
Assuming the number of users who could possibly be affected by this issue is low, I have marked the priority as S4.
Steps to reproduce
- Create two orders in the
sales_ordertable using different store IDs, and the sameincrementId - Call
loadByIncrementId
Expected result
loadByIncrementIdshould return a list of orders
Actual result
loadByIncrementIdselects an order if multiple match
Additional information
No response
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status