Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3017

UnitOfWork::$entityIdentifiers does not get updated when saving composite PK with a JoinColum as PK

    Details

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

      Description

      The Sonata Admin Bundle rely on the ``UnitOfWork::getEntityIdentifier`` method to retrieve the object identifier.

      We are adding support for composite PK with a FK as described in the gist: https://gist.github.com/rande/9439778 .

      The bug occurs when the Material reference is updated on the Color object. The Color has a new set of PK. However the UnitOfWork::$entityIdentifiers is not updated when the object is persisted. So the values stored ``UnitOfWork::$entityIdentifiers`` are invalid for the Color object.

      The consequence is that we are unable to redirect the user once the object is saved as the UnitOfWork::getEntityIdentifier refers to the old values.

        Activity

        Hide
        Marco Pivetta added a comment -

        Thomas Rabaix can you please come up with a failing test case for this issue?

        Show
        Marco Pivetta added a comment - Thomas Rabaix can you please come up with a failing test case for this issue?
        Hide
        Benjamin Eberlei added a comment -

        It is not supported to change the identifier. They are assumed to be immutable by Doctrine and we cannot change that, as the consequences are impossible to handle.

        Show
        Benjamin Eberlei added a comment - It is not supported to change the identifier. They are assumed to be immutable by Doctrine and we cannot change that, as the consequences are impossible to handle.
        Hide
        Thomas Rabaix added a comment -

        Thanks for commenting this issue. So with composite keys the assumption is wrong and from your comment this bug is the expected behavior.

        Now, should doctrine provide a secure method to retrieve the identifier keys ?

        Show
        Thomas Rabaix added a comment - Thanks for commenting this issue. So with composite keys the assumption is wrong and from your comment this bug is the expected behavior. Now, should doctrine provide a secure method to retrieve the identifier keys ?
        Hide
        Marco Pivetta added a comment -

        Thomas Rabaix shouldn't you extract identifiers via metadata by having an instance of an entity?

        Show
        Marco Pivetta added a comment - Thomas Rabaix shouldn't you extract identifiers via metadata by having an instance of an entity?
        Hide
        Thomas Rabaix added a comment -

        It is what I did: https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/master/Model/ModelManager.php#L277-L303

        However it will be better to have a clean implementation in the ORM.

        Show
        Thomas Rabaix added a comment - It is what I did: https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/master/Model/ModelManager.php#L277-L303 However it will be better to have a clean implementation in the ORM.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Thomas Rabaix
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: