Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3179

Non initialized Proxy object with post remove listener

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:

      Description

      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?

        Issue Links

          Activity

          Hide
          Marco Pivetta added a comment -

          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.

          Show
          Marco Pivetta added a comment - 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.
          Hide
          Marco Pivetta added a comment -

          Resolution in DDC-3180

          Show
          Marco Pivetta added a comment - Resolution in DDC-3180

            People

            • Assignee:
              Marco Pivetta
              Reporter:
              Geoffrey Brier
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: