mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
PostRemove on an orphanRemoval is not called #5397
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @johndodev on GitHub (Jan 25, 2017).
Originally assigned to: @lcobucci on GitHub.
Hello, I'm also facing an event problem of orphanRemoval (postDelete).
The simpler example is an user with an avatar one-to-one field, wich is an StoredFile entity.
When I set avatar to null, the StoredFile is removed from the database, but the postRemove seems not executed, and this is where I want to remove the file from the filesystem (is this a bad design ?).
Is this a bug ?
@Ocramius commented on GitHub (Jan 25, 2017):
No, this seems fine (compared to most listener usages :-) )
Can a scenario be created? Look at
9c76c3766f/tests/Doctrine/Tests/ORM/Functional/Ticket@johndodev commented on GitHub (Jan 25, 2017):
Is this one ok ?
c28d15a585/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6256Test.phpShould I make a PR ? On which branch (I used 2.5 cause I don't have php7 yet - mailparse needed) ?
So on the test file, the first one is passing, not the second one.
@Ocramius commented on GitHub (Jan 25, 2017):
@johndodev please send a PR against
masterfor evaluation, and yes: that's perfect! Travis-CI will test PHP7 for you, no problem :-)@johndodev commented on GitHub (Mar 16, 2017):
Re,
The test do pass (I made a misstake). So I did some research again on my code and the conclusion that the listener was not called was wrong.
It is called, but the entity passed to the postRemove event is a proxy, with a null ID. So it can't be loaded, but doctrine try to, and give me a "random" entity in the database (always the same, but neither the first one nor the last).
Sooo, where is the error here ? The fact that the proxy is passed in the postRemove listener ? Or the fact that doctrine try to load an entity with a null id (and success to) ? Or something else ?