DDC-3179: Non initialized Proxy object with post remove listener #3939

Closed
opened 2026-01-22 14:31:57 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Jun 19, 2014).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user geoffrey.brier:

Hi,

My use case is as follow:
I have an object "Demand" linked to a "Guarantor" which possesses a few files to delete from the server on the "post remove" doctrine event. The Demand -> Guarantor relation is configured to cascade persist and remove on the ORM side.

We intended to remove a "Demand" object but were getting an "EntityNotFoundException". After debugging a bit with a friend (eric geloen) we realized that when non initialized proxies have a listener on the post remove event, the object cannot loads itself as it does not exist anymore and this throws an exception. In my case, this means that I cannot delete the "Guarantor's" files.

So I was wondering if it was a bug coming from doctrine or a normal behavior. One could consider that it is our responsibility to correctly load an object and its graph yet one could also consider that this is a limitation (not to initialize the proxies beforehand).

While testing we moved the following snippet (that was in the cascadeRemove method) in the "executeDeletions" method right before the delete call and it was working.

if ($entity instanceof Proxy && !$entity->*_isInitialized_*) {
    $entity->**load();
}

What is your opinion?

Originally created by @doctrinebot on GitHub (Jun 19, 2014). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user geoffrey.brier: Hi, My use case is as follow: I have an object "Demand" linked to a "Guarantor" which possesses a few files to delete from the server on the "post remove" doctrine event. The Demand -> Guarantor relation is configured to cascade persist and remove on the ORM side. We intended to remove a "Demand" object but were getting an "EntityNotFoundException". After debugging a bit with a friend (eric geloen) we realized that when non initialized proxies have a listener on the post remove event, the object cannot loads itself as it does not exist anymore and this throws an exception. In my case, this means that I cannot delete the "Guarantor's" files. So I was wondering if it was a bug coming from doctrine or a normal behavior. One could consider that it is our responsibility to correctly load an object and its graph yet one could also consider that this is a limitation (not to initialize the proxies beforehand). While testing we moved the following snippet (that was in the cascadeRemove method) in the "executeDeletions" method right before the delete call and it was working. ``` if ($entity instanceof Proxy && !$entity->*_isInitialized_*) { $entity->**load(); } ``` What is your opinion?
admin added the Bug label 2026-01-22 14:31:57 +01:00
admin closed this issue 2026-01-22 14:31:57 +01:00
Author
Owner
@doctrinebot commented on GitHub (Jun 19, 2014): - is required for [DDC-3180: [GH-1065] [DDC-3179] EntityNotFoundException on the postRemove event if the entity is a proxy](http://www.doctrine-project.org/jira/browse/DDC-3180)
Author
Owner

@doctrinebot commented on GitHub (Jun 19, 2014):

Comment created by @ocramius:

[~geoffrey.brier] this may be a bug, but it needs a test case reproducing your exact scenario.

It would also be interesting to look at what you have so far.

Also, lowering priority.

@doctrinebot commented on GitHub (Jun 19, 2014): Comment created by @ocramius: [~geoffrey.brier] this may be a bug, but it needs a test case reproducing your exact scenario. It would also be interesting to look at what you have so far. Also, lowering priority.
Author
Owner

@doctrinebot commented on GitHub (Jun 26, 2014):

Comment created by @ocramius:

Resolution in DDC-3180

@doctrinebot commented on GitHub (Jun 26, 2014): Comment created by @ocramius: Resolution in [DDC-3180](http://www.doctrine-project.org/jira/browse/DDC-3180)
Author
Owner

@doctrinebot commented on GitHub (Jun 26, 2014):

Issue was closed with resolution "Won't Fix"

@doctrinebot commented on GitHub (Jun 26, 2014): Issue was closed with resolution "Won't Fix"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3939