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

Changing Media entity twice in same request is trying to delete directory #141

Closed
liquorvicar opened this issue Nov 12, 2015 · 5 comments
Closed

Comments

@liquorvicar
Copy link

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:

        $this->em->persist($mediaEntity);
        $this->em->flush();

        $fileSource->process($mediaEntity);

        $this->em->flush($mediaEntity);

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?

@dbu
Copy link
Member

dbu commented Nov 12, 2015

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.

@liquorvicar
Copy link
Author

Aaaaargh, posted to the wrong place. The issue I have is with Sonata and not Symfony CMF directly.

Hangs head in shame...

@uwej711
Copy link
Member

uwej711 commented Nov 12, 2015

I think that could be related: doctrine/phpcr-odm#661

Can you try that branch of phpcr-odm to find out whether this still happens?

@liquorvicar
Copy link
Author

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

@uwej711
Copy link
Member

uwej711 commented Nov 12, 2015

OK, you are right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants