-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions and environment
- Magento version 2.4.x
The official patch ACSD-67166 (https://experienceleague.adobe.com/en/docs/commerce-operations/tools/quality-patches-tool/patches-available-in-qpt/v1-1-70/acsd-67166) has the following change in the file Magento\InventoryCatalog\Model\LegacyStockStatusCache:
// Filter out product IDs that are already cached
$productIdsToLoad = array_filter($productIds, function ($productId) use ($scopeId) {
return $this->legacyStockStatusStorage->get((int)$productId, $scopeId) !== null;
According to the PHP function definition of array_filter (https://www.php.net/manual/en/function.array-filter.php), this piece of code seems to be doing the opposite of what it is intending to do:
If the callback function returns true, the current value from array is returned into the result array.
This means $productIdsToLoad is going to be a list of product Ids that are already cached which is the opposite of what is desired (list of product IDs excluding those already cached). This means that $productIdsToLoad is always empty, and the legacyStockCache never gets preloaded. The callback function should be checking for null, not not null.
Steps to reproduce
- Set a breakpoint in the
array_filtercallback function.
$this->legacyStockStatusStorage->get() returns null if the product is not cached which means that $this->legacyStockStatusStorage->get((int)$productId, $scopeId) !== null; returns true when the product is cached.
Expected result
Uncached product ids are added to $productIdsToLoad which in turn are then loaded and added to the legacy stock status storage.
Actual result
Uncached product ids are not added to $productIdsToLoad which in turn are then loaded and added to the legacy stock status storage.
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