Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-2839

[GH-869] Detach objects in original object data


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


      This issue is created automatically through a Github pull request on behalf of tomphp:

      Url: https://github.com/doctrine/doctrine2/pull/869


      The PR makes Doctrine ORM update the database when you execute something like this:

      // MyEntity.php


      • @Entity
        class MyEntity
        // ...


      • @Column(type="datetime")
        private $created;

      // ...

      public function setCreated(\DateTime $created)

      { $this->created = $created; }

      public function getCreated()

      { return $this->created; }

      // ...

      // Current problem

      $entity = $entityManager->find('MyEntity', 1);




      // At this point no changes have been made to the database!

      The reason this doesn't work currently is because the array of original data stored in the UnitOfWork contains the actual DateTime object which is in the entity. When you update the object in the entity the original data is updated also so the entity are the original value are still equal and therefore the object is not seen as changed.

      I have chosen to clone all objects rather than just DateTime object include more types are included in the future.

        Issue Links


          doctrinebot Doctrine Bot created issue -
          ocramius Marco Pivetta made changes -
          Field Original Value New Value
          Status Open [ 1 ] Resolved [ 5 ]
          Assignee Benjamin Eberlei [ beberlei ] Marco Pivetta [ ocramius ]
          Resolution Invalid [ 6 ]
          ocramius Marco Pivetta made changes -
          Remote Link This issue links to "Working with DateTime and Doctrine ORM (Web Link)" [ 10032 ]


            • Assignee:
              ocramius Marco Pivetta
              doctrinebot Doctrine Bot
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: