Magento2: Product repository "get" method returns error if called more than 1000 times

Created on 20 Nov 2017  路  2Comments  路  Source: magento/magento2

Preconditions

  1. Magento 2.2.1

Steps to reproduce

  1. Setup a database with more than 1000 different products
  2. Call repository get method with different SKUs

Expected result

  1. Each call returns a product by SKU

Actual result

After some calls:

PHP Notice:  Undefined offset: <SKU_STRING_XYZ> in /vendor/magento/module-catalog/Model/ProductRepository.php on line 254

Seems like the problem is in the following:

  • cacheProduct method is called for each found item.
  • If cacheLimit field is set (1000 by default) and number if cached items exceeds this limit, then cache array is sliced by a half.
  • Then repository method gets item from cache and it might happen that this key was in sliced half. So it results in error.
Cannot Reproduce Format is valid needs update

Most helpful comment

@dankocherga I believe this was fixed in https://github.com/magento/magento2/commit/3b50751687f873a645b914194228e0006fa1cb1b which will be released in 2.2.2.

All 2 comments

@dankocherga, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.3.0-dev, 2.1.10, 2.2.1

@dankocherga I believe this was fixed in https://github.com/magento/magento2/commit/3b50751687f873a645b914194228e0006fa1cb1b which will be released in 2.2.2.

Was this page helpful?
0 / 5 - 0 ratings