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

Error filtering template: Warning: getimagesize: failed to open stream: No such file or directory in app/code/Magento/Catalog/Model/Product/Image.php #1647

Closed
dmitrii-fediuk opened this issue Aug 11, 2015 · 8 comments

Comments

@dmitrii-fediuk
Copy link

The problem line is:

$fileInfo = getimagesize($this->_mediaDirectory->getAbsolutePath($this->_newFile));

@robbieaverill
Copy link

Hi @dfediuk - can you provide steps to reproduce this error?

@dmitrii-fediuk
Copy link
Author

  1. Pulled Magento 2 version noted above
  2. Restarted Apache and cleared the cache:
net stop "Apache2.4" && net start "Apache2.4" &&
find var/* -type f -or -type d | grep -v 'session' | xargs rm -rf && 
rm -rf pub/static/*
  • Ran bin/magento setup:upgrade
  • Opened the frontend

The same error report from another user: http://magento.stackexchange.com/questions/78520
My quick fix: https://mage2.pro/t/49

@mttjohnson
Copy link

I am seeing this same behavior. I was able to reproduce the issue by flushing the image cache from the admin or by deleting the files in pub/media/catalog/product/cache/. After the cached image files are created there are no problems going forward, but there appears to be an issue in recreating cached image files if they do not already exist.

I was testing this on a build from the develop branch from August 18th: https://github.com/magento/magento2/commit/2dba9a553802acdb81a2ea9acf124c98810fa4a2

I initially built some sample products in the admin and used them for testing some functionality, then went to remove a product image to test some behavior, I noticed the image still displayed on the frontend even though I removed the product image on the admin, so I flushed the image cache, and then the site failed to load any category or product pages.

Warning: getimagesize(/Volumes/Server/www/m2test.dev/htdocs/pub/media/catalog/product/cache/1/image/265x265/beff4985b56e3afdbeabfc89641a4582/m/h/mh12-gg_main.jpg): failed to open stream: No such file or directory in /Volumes/Server/www/m2test.dev/htdocs/app/code/Magento/Catalog/Model/Product/Image.php on line 939

I implemented dfediuk's quick fix and confirmed it to resolve the issue, though I didn't look into why this behavior exists, and what the best way is of correcting it.

if (!$this->isCached()) {
  $this->saveFile();
}

I also ran into this same problem from importing a database from another Magento 2 installation. I had loaded the pub/media/catalog/product/ directory with all the product images, but did not include the cache directory expecting it to rebuild the cached images. The symptoms I was seeing was that the home page would load but category page and product pages would not load since it would run into errors trying to get the image size in the getResizedImageInfo() method.

@davidalger
Copy link
Member

This appears to be a regression from 1.0.0-beta, but I believe it's fixed in latest develop as I can no longer reproduce the issue after pulling from upstream/develop in my local installation with sample data.

I was consistently able to reproduce with sample data on rev a1393fc (the one I happened to have checked out), but the issue did not occur when rolling back to the 1.0.0-beta tag. Pulling in the latest develop at rev 50d6f9a also resolved the issue for me and I could no longer reproduce it.

Steps to reproduce were as follows:

  1. clear out caches including the image cache

    rm -rf var/*/*
    redis-cli flushall
    pub/media/catalog/product/cache/
    
  2. load the page in a browser

Failed result: running an ls -d pub/media/catalog/product/cache/ would result in the message ls: cannot access pub/media/catalog/product/cache/: No such file or directory.

Successful result: images show up on the frontend after following the above steps and are correctly populated into the pub/media/catalog/product/cache/ directory.

@mttjohnson
Copy link

I expect this commit addressed the problem:
f79ffb1

@davidalger
Copy link
Member

@mttjohnson I suspect you're right. ;)

@piotrekkaminski
Copy link
Contributor

@davidalger is it working now?

@davidalger
Copy link
Member

@piotrekkaminski It is, yes, and we have not run into the issue since Aug.

magento-team pushed a commit that referenced this issue Nov 2, 2017
[Helix] MAGETWO-65466 [Backport] - Issue when deleting item from Product options grid containing more than 20 options - for 2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants