I have an error that occurs in production only. And even then it is about 3/10 times that it occurs. Refresh, seems alright, refresh again, seems broken etc. On the staging site + my docker box it seems to work fine.
So the problem: The configurable product page is not being build 3 out of 10 times. Only a part of the following theme template is visible: Magento_ConfigurableProduct/templates/product/view/type/options/configurable.phtml .
The error starts from the $block->getJsonConfig() function in the template. It eventually calls on the function: $this->getData('media_gallery_images')->count(). This resides in: vendor/magento/module-catalog/Model/Product.php
This results in the error: Call to a member function count() on array.
The function: $this->getData('media_gallery_images') should always return an object as far as I know. So when it is an array it seem logical that it errors. I just cant figure out why it returns an array. Before that piece of code it also does the hasData check (with the setData) if it the check is false.
If you have an idea of the source of this problem, please post. I will investigate it then because I am at a loss at the moment.
Data: Magento 2.3.5 PHP 7.1.33