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

[CE 2.1.0] Fatal issue on BO edit page if a media has been directly deleted on the server #5871

Closed
spipu opened this issue Jul 28, 2016 · 6 comments

Comments

@spipu
Copy link

@spipu spipu commented Jul 28, 2016

Hi,

The steps are :

  • Create a product and add a media in the "Images and Videos" tab.
  • Go on the product view page in BO : it works
  • Delete the image directly on the server to simulate a accidental lost of data
  • Go on the product view page in BO : the following error occurs without the possibility to edit the product :

Cannot gather stats! Warning!stat(): stat failed for /var/www/xxxx/pub/media/catalog/product/w/s/ws02-green_main.jpg

It is because there is no protection here:

https://github.com/magento/magento2/blob/2.1/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php#L135

I think it could be a good think to do something like this :

    public function getImagesJson()
    {
        $value = $this->getElement()->getImages();
        if (is_array($value) &&
            array_key_exists('images', $value) &&
            is_array($value['images']) &&
            count($value['images'])
        ) {
            $directory = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA);
            $images = $this->sortImagesByPosition($value['images']);
            foreach ($images as &$image) {
                $image['url'] = $this->_mediaConfig->getMediaUrl($image['file']);
                try {
                    $fileHandler = $directory->stat($this->_mediaConfig->getMediaPath($image['file']));
                    $image['size'] = $fileHandler['size'];
                } catch (\Exception $e) {
                    $image['size'] = 0;
                    // @todo add some log
                }
            }
            return $this->_jsonEncoder->encode($images);
        }
        return '[]';
    }
@erikhansen

This comment has been minimized.

Copy link
Contributor

@erikhansen erikhansen commented Aug 17, 2016

I'm seeing the same issue on 2.1.

@pboisvert

This comment has been minimized.

Copy link

@pboisvert pboisvert commented Aug 17, 2016

Anton--can you take a look at this? While marked as "improvement" i think the impact here feels like a bug in terms of missing protection from scenario of one or more product images being deleted from the server. We must fix to ensure product edit page still available.

@antboiko

This comment has been minimized.

Copy link

@antboiko antboiko commented Aug 18, 2016

Hi @spipu , thanks for reporting. We already have internal ticket MAGETWO-54718 for fixing this issue and we're working on it.

Best
Anton.

mmansoor-magento pushed a commit that referenced this issue Sep 2, 2016
[EAST] MAGETWO-54718: [GitHub] Exception thrown where no Product Image file found #5184 #5497 #5871
@KevinMace

This comment has been minimized.

Copy link
Member

@KevinMace KevinMace commented Oct 3, 2016

I'm seeing the same issue on 2.1.1 EE

@spipu spipu closed this Dec 9, 2016
okorshenko pushed a commit that referenced this issue Dec 14, 2016
- MAGETWO-54718: [GitHub] Exception thrown where no Product Image file found #5184 #5497 #5871

- (cherry picked from commit 1ef843d)
okorshenko pushed a commit that referenced this issue Dec 14, 2016
- MAGETWO-54718: [GitHub] Exception thrown where no Product Image file found #5184 #5497 #5871

- (cherry picked from commit 2240a1e)
okorshenko pushed a commit that referenced this issue Dec 14, 2016
- MAGETWO-54718: [GitHub] Exception thrown where no Product Image file found #5184 #5497 #5871

- (cherry picked from commit da52cad)
okorshenko pushed a commit that referenced this issue Dec 14, 2016
- MAGETWO-54718: [GitHub] Exception thrown where no Product Image file found #5184 #5497 #5871

- (cherry picked from commit 0bad8ab)
@elenleonova

This comment has been minimized.

Copy link

@elenleonova elenleonova commented Dec 15, 2016

The issue has been delivered to 2.1.3

@spipu

This comment has been minimized.

Copy link
Author

@spipu spipu commented May 12, 2017

tested, ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.