Closed liquorvicar closed 8 years ago
generally doing things in doctrine event listeners can be tricky. do you see a way to do it with a custom symfony event? otherwise, if you see a way how this could properly work, please do a bugfix pull request.
Aaaaargh, posted to the wrong place. The issue I have is with Sonata and not Symfony CMF directly.
Hangs head in shame...
I think that could be related: https://github.com/doctrine/phpcr-odm/pull/661
Can you try that branch of phpcr-odm to find out whether this still happens?
@uwej711 No, don't think it's related. I posted to the wrong place, we're using the Sonata Media bundle and regular doctrine entities, not Symfony-CMF/phpcr.
OK, you are right.
We have a situation where we create a Media entity using a dummy file, then after we have saved it (and can get a provider reference for where the image is stored) we set the file size etc. When we make the second change the postUpdate doctrine lifecycle event is trying to delete the whole directory.
Our code in question:
On the second flush, the code in \Sonata\MediaBundle\Provider\FileProvider::postUpdate is deleting the current file from the filesystem using $media->getPreviousProviderReference() which is null.
Is this a bug?