Skip to content

Commit f3e91d4

Browse files
authored
ProductRepository sku cache is destroyed when cacheLimit is reached
Nummeric SKUs are renumbered when array_slice is used to purge parts of the products-by-sku cache array. Per php documentation: > Note that array_slice() will reorder and reset the numeric array indices by default. as `$this->instances` has the SKUs as keys, the resulting shortened array might contain indexes that now point to a wrong product.
1 parent ad44399 commit f3e91d4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ private function cacheProduct($cacheKey, \Magento\Catalog\Api\Data\ProductInterf
312312
if ($this->cacheLimit && count($this->instances) > $this->cacheLimit) {
313313
$offset = round($this->cacheLimit / -2);
314314
$this->instancesById = array_slice($this->instancesById, $offset, null, true);
315-
$this->instances = array_slice($this->instances, $offset);
315+
$this->instances = array_slice($this->instances, $offset, null, true);
316316
}
317317
}
318318

0 commit comments

Comments
 (0)