Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugged Interaction Between Collection Cache and Configurable Products Gallery #33965

Closed
1 of 5 tasks
JamesFX2 opened this issue Sep 1, 2021 · 16 comments
Closed
1 of 5 tasks
Assignees
Labels
Component: Cache Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@JamesFX2
Copy link

JamesFX2 commented Sep 1, 2021

We noticed occasional errors in site logs

Preconditions (*)

  1. 2.3.5 - 2.4 develop

Steps to reproduce (*)

  1. When the getOptionsMediaGalleryDataJson() method is called in \Magento\Catalog\Block\Product\View\Gallery
  2. 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.
  3. This is then intercepted by the plugin as Magento\ConfigurableProduct\Model\Plugin\Front\UsedProductsCache which serializes the array of items loaded.
  4. 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' => []
  5. 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 (*)

  1. Collection of DataObjects returned with images from the gallery / JSON array

Actual result (*)

  1. [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.

  • 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”.
@m2-assistant
Copy link

m2-assistant bot commented Sep 1, 2021

Hi @JamesFX2. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-assistant
Copy link

m2-assistant bot commented Sep 6, 2021

Hi @engcom-Delta. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Delta engcom-Delta added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Sep 6, 2021
@m2-assistant
Copy link

m2-assistant bot commented Sep 6, 2021

Hi @engcom-Lima. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Lima
Copy link
Contributor

engcom-Lima commented Sep 15, 2021

Hi @JamesFX2,

Thank you for reporting the issue. But the information provided is not enough for me to reproduce this.

I think you were explaining the inner functionality of how errors might be coming but it is unclear on how I can replicate this issue on 2.4-develop instance. Can you be more specific with the details like if you are facing this issue on Admin Panel or Frontend ? Update the 'Steps to reproduce' so that I can follow it to produce these errors.

@engcom-Lima engcom-Lima added Component: Cache Issue: needs update Additional information is require, waiting for response labels Sep 15, 2021
@engcom-Lima engcom-Lima added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Sep 15, 2021
@engcom-Hotel
Copy link
Contributor

Dear @JamesFX2,

We have noticed that this issue has not been updated for a period of 14 Days. Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket if you need more assistance on this.

Regards

@convenient
Copy link
Contributor

@JamesFX2 do you have a workaround for this at all?

@JamesFX2
Copy link
Author

Yeah, I just put a plugin on Magento\Catalog\Model\Product

<?php

namespace Company\Module\Plugin\Catalog\Model;

class Product
{
    public function beforeGetMediaGalleryImages(\Magento\Catalog\Model\Product $subject)
    {
        
        if($subject->hasData('media_gallery_images')){
            $images = $subject->getData('media_gallery_images');
            if(!is_object($images)){
                $subject->unsetData('media_gallery_images');
            }
        }
    }
}`

@serzhik
Copy link
Contributor

serzhik commented Feb 15, 2022

@JamesFX2 in my case https://github.com/PHOENIX-MEDIA/magento2-mediastoragesync breaks standard flow as you described.

@convenient
Copy link
Contributor

FWIW i saw this dropping off after upgrading to 2.4.3

@friendscottn
Copy link

This is still an issue in 2.4.5

@serzhik
Copy link
Contributor

serzhik commented Jan 24, 2023

Issue still present in 2.4.5-p1

@artttj
Copy link

artttj commented May 16, 2023

Same here. We faced that issue in 2.4.5-p1 - when you open dozens of configurable products simultaneously in new tabs.

@Buzzorus
Copy link

Buzzorus commented Jan 10, 2024

Had same issue. @JamesFX2 Plugin fixed the problem

Magento version: Magento CLI 2.3.5-p1

Fetched with Frontend response
bug

{
    "[data-role=swatch-options]": {
        "Magento_Swatches/js/swatch-renderer": {
            "jsonConfig": <br />

Fatal error: Uncaught Error: Call to a member function count() on array in /data01/virt65663/domeenid/www.pood24.ee/htdocs/vendor/magento/module-catalog/Model/Product.php:1533
Stack trace:
#0 /data01/virt65663/domeenid/www.pood24.ee/htdocs/vendor/magento/module-configurable-product/Helper/Data.php(52): Magento\Catalog\Model\Product->getMediaGalleryImages()
#1 /data01/virt65663/domeenid/www.pood24.ee/htdocs/vendor/magento/module-configurable-product/Block/Product/View/Type/Configurable.php(262): Magento\ConfigurableProduct\Helper\Data->getGalleryImages(Object(Magento\Catalog\Model\Product\Interceptor))
#2 /data01/virt65663/domeenid/www.pood24.ee/htdocs/vendor/magento/module-configurable-product/Block/Product/View/Type/Configurable.php(239): Magento\ConfigurableProduct\Block\Product\View\Type\Configurable->getOptionImages()
#3 /data01/virt65663/domeenid/www.pood24.ee/htdocs/vendor/magento/framework/Interception/Interceptor.php(58): Magento\ConfigurableProduct\Block\Product\View\Type\Configurable->getJsonConfig()
#4 /data01/ in /data01/virt65663/domeenid/www.pood24.ee/htdocs/vendor/magento/module-catalog/Model/Product.php on line 1533

@zaietsv
Copy link

zaietsv commented Mar 20, 2024

The issue still presents at Magento 2.4.6-p3

@buderus199
Copy link

Issue still present in 2.4.5-p5. It happens randomly. I haven't find why it is triggered.

@zaietsv
Copy link

zaietsv commented Aug 6, 2024

@buderus199 that's funny that the @engcom-Lima supposes the task is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Cache Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
None yet
Development

No branches or pull requests