Sylius: Image files are not deleted from disk when image resources are removed from database

Created on 2 Aug 2017  Â·  3Comments  Â·  Source: Sylius/Sylius

Hello Sylius Team,

I'm not really sure if it's really a bug but i was told to open an issue here.
Problem is pretty self explanatory, when successfully removing an image resource from database, the actual image file referenced by this entity is not deleted from disk (neither the source file nor the cached file).

Test cases:

  • delete product taxon with image(s) from admin panel and admin API
  • delete product with image(s) from admin panel and admin API

Same result every time, files are not deleted from disk.

Environment:
mysql 15.1 Distrib 10.1.25-MariaDB
Linux 4.11.11-200.fc25.x86_64
PHP 7.0.21

Potential Bug

All 3 comments

What would be the wanted behaviour here?
Sylius images are stored in randomly named folders (and those folders may contain another image), so this might mean a heavy workload when deleting a resource with a collection of images.
Also it's using Gaufrette so not sure if remove operations are sufficiently supported.
Should the cached images be removed too?
Cached image paths need to be resolved first (using LiipImagineBundle cache resolver), so that means using the controller as a service.

What would be the wanted behaviour here?

I would expected the related images to be deleted too when deleting a record.

Sylius images are stored in randomly named folders (and those folders may contain another image), so this might mean a heavy workload when deleting a resource with a collection of images.

The image path is saved in a db field isn't it (For e.g. sylius_product_image has path field)? So I don't see a problem getting the required path for deleting files.

Also it's using Gaufrette so not sure if remove operations are sufficiently supported.
Should the cached images be removed too?
Cached image paths need to be resolved first (using LiipImagineBundle cache resolver), so that means using the controller as a service.

I would expected the cached images to be removed too. I am not familiar with Gaufrette so don't how who easy or difficult it would be to have it delete all cached version of a particular image. If it's lot of effort then perhaps consider using another image resizing library. Glide for e.g. allow you to easily delete all resized cached versions of a particular image.

Fixed in #8585, both caches & filesystem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikemix picture mikemix  Â·  3Comments

eb22fbb4 picture eb22fbb4  Â·  3Comments

loic425 picture loic425  Â·  3Comments

bnd170 picture bnd170  Â·  3Comments

mezoni picture mezoni  Â·  3Comments