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:
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
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.