Description
Preconditions and environment
When there is a customer segment rule with any Product List condition, AND a guest without the quote performs any POST request, the following SQL query is ran in \Magento\CustomerSegment\Model\Segment\Condition\Product\Combine\ListCombine::isSatisfiedBy:
SELECT item.* FROM quote_item item INNER JOIN quote ON item.quote_id = quote.entity_id WHERE ( quote.store_id IN( ? ) ) AND ( quote.is_active = ? )
This is incorrect behavior, and has two undesired consequences:
- Segment Rule is applied based on all active quote items for this store, not on guest's quote.
- The SQL request above is executed without index keys applied, and for huge quote_item table this creates a significant MaridDB overload for a significant number of POST requests.
This should never happen for the guests that do not have quotes.
- Magento version 2.4.7-p3
Steps to reproduce
- Create a new Customer Segment. Set Apply To to Visitors or Visitors and Registered Customers. In conditions, select a single [Products] Product List condition, and select any subcondition for it (for instance, Attribute Set is Shirts).
- In incognito browser window, navigate to the site frontend. Perform any POST request which does not create quote (for instance, submit Contact Us form).
Expected result
Product List condition is processed correctly - if guest doesn't have quote, \Magento\CustomerSegment\Model\Segment\Condition\Product\Combine\ListCombine::isSatisfiedBy returns value based on the operator only (and not getting to the quote items request)
Actual result
The SQL query above is ran. No indexes are used, which overloads MariaDB, and segment is applied based on someone else's quotes.
Additional information
The following patch solves the problem
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”.