I recently started setting up a dockerized October CMS environment based on Alpine Linux, MariaDB and PHP-FPM which was actually a very straightforward process. However, for some reason the integrated image resizer didn’t create thumbnails of uploaded images.
Unfortunately there was nothing in the log files which could help me to identify the cause of the problem. After checking the file permissions, I decided to trace back the issue and found the reason in file vendor/october/rain/src/Database/Attach/Resizer.php.
The method getMimeType() returned always null, which broke the entire image manipulation process.
// Get the file extension
$this->extension = $file->guessExtension();
$this->mime = $file->getMimeType();
After a quick research I found out that getMimeType requires php_fileinfo which I simply forgot to set in my Dockerfile. After adding php7-fileinfo and rebuilding the container, the issue was finally fixed.
Today I imported a couple of new products with uRapidFlow in Magento 2.1.2. I ran the import with the option Action on missing image file which was set to WARNING and update image field. It worked fine, but I accidentally forgot to upload the product images.
So basically uRapidFlow added non-existing product images to the database which broke the product edit form in the admin panel.
Cannot gather stats! Warning!stat(): stat failed for /var/www/src/pub/media/catalog/product/A_217823.JPG
The temporarily solution was to manipulate ./vendor/magento/module-catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php in vendor around line 142,143.
$fileHandler = $mediaDir->stat($this->_mediaConfig->getMediaPath($image['file']));
$image['size'] = $fileHandler['size'];
I basically added is_readable to check if the file exists. Not great, but at least I was able to edit products again and proceed with a permanent fix.