We noticed occasional errors in site logs
Preconditions (*)
- 2.3.5 - 2.4 develop
Steps to reproduce (*)
- When the getOptionsMediaGalleryDataJson() method is called in \Magento\Catalog\Block\Product\View\Gallery
- If the product is a configurable product, the plugin at \Magento\ConfigurableProduct\Block\Plugin\Product\Media\Gallery is called and calls the type instance's getUsedProducts method.
- This is then intercepted by the plugin as Magento\ConfigurableProduct\Model\Plugin\Front\UsedProductsCache which serializes the array of items loaded.
- The next time another instance of the Product needs to pull in getUsedProducts, it's loaded from the frontend cache which unserializes the data, creates new instances of Products via the Factory method but the problem occurs when somehow, one of the array of Products that was saved has already called getMediaGalleryImages() so has a value set for 'media_gallery_images' - when this is unserialized, it's just created as 'media_gallery_images' => []
- So when the block now calls getOptionsMediaGalleryDataJson() since the Product has a value for 'media_gallery_images', line 1560 causes an error. Please consider modifying this to check.
Expected result (*)
- Collection of DataObjects returned with images from the gallery / JSON array
Actual result (*)
-
[31-Aug-2021 21:26:44 UTC] PHP Fatal error: Uncaught Error: Call to a member function count() on array in /home/cloudpanel/htdocs/www.redacted.com/releases/2021_08_27_10_55_43_branch_v2.3.5-72/vendor/magento/module-catalog/Model/Product.php:1533
Stack trace:
#0 /home/cloudpanel/htdocs/www.redacted.com/releases/2021_08_27_10_55_43_branch_v2.3.5-72/vendor/magento/module-configurable-product/Block/Plugin/Product/Media/Gallery.php(62): Magento\Catalog\Model\Product->getMediaGalleryImages()
#1 /home/cloudpanel/htdocs/www.redacted.com/releases/2021_08_27_10_55_43_branch_v2.3.5-72/vendor/magento/module-configurable-product/Block/Plugin/Product/Media/Gallery.php(49): Magento\ConfigurableProduct\Block\Plugin\Product\Media\Gallery->getProductGallery(Object(Magento\Catalog\Model\Product\Interceptor))
#2 /home/cloudpanel/htdocs/www.redacted.com/releases/2021_08_27_10_55_43_branch_v2.3.5-72/vendor/magento/framework/Interception/Interceptor.php(146): Magento\ConfigurableProduct\Block\Plugin\Product\Media\Gallery->afterGetOptionsMediaGalleryDataJson(Objec in /home/cloudpanel/htdocs/www.redacted.com/releases/2021_08_27_10_55_43_branch_v2.3.5-72/vendor/magento/module-catalog/Model/Product.php on line 1533
[31-Aug-2021 21:26:48 UTC] PHP Fatal error: Uncaught Error: Call to a member function count() on array in /home/cloudpanel/htdocs/www.redacted.com/releases/2021_08_27_10_55_43_branch_v2.3.5-72/vendor/magento/module-catalog/Model/Product.php:1533
Stack trace:
#0 /home/cloudpanel/htdocs/www.redacted.com/releases/2021_08_27_10_55_43_branch_v2.3.5-72/vendor/magento/module-configurable-product/Block/Plugin/Product/Media/Gallery.php(62): Magento\Catalog\Model\Product->getMediaGalleryImages()
#1 /home/cloudpanel/htdocs/www.redacted.com/releases/2021_08_27_10_55_43_branch_v2.3.5-72/vendor/magento/module-configurable-product/Block/Plugin/Product/Media/Gallery.php(49): Magento\ConfigurableProduct\Block\Plugin\Product\Media\Gallery->getProductGallery(Object(Magento\Catalog\Model\Product\Interceptor))
#2 /home/cloudpanel/htdocs/www.redacted.com/releases/2021_08_27_10_55_43_branch_v2.3.5-72/vendor/magento/framework/Interception/Interceptor.php(146): Magento\ConfigurableProduct\Block\Plugin\Product\Media\Gallery->afterGetOptionsMediaGalleryDataJson(Objec in /home/cloudpanel/htdocs/www.redacted.com/releases/2021_08_27_10_55_43_branch_v2.3.5-72/vendor/magento/module-catalog/Model/Product.php on line 1533
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
We noticed occasional errors in site logs
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.