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

Merging serialized entity back to the UnitOfWork


    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.4
    • Fix Version/s: 2.1.6, 2.2
    • Component/s: ORM
    • Security Level: All
    • Labels:
    • Environment:
      Windows 7, Apache, PHP 5.3.8, Zend Framework


      (I'm using doctrine 2.1.4.)

      I'm trying to merge an Entity back to the UnitOfWork.
      The Entity is created from a serialized object (The deserialzed Entity is a valid Entity Object. The only difference
      is that it is not managed by Doctrine yet) and I'm using the merge
      method of the EntityManager to get it in managed state again.

      This results in a call of the Method doMerge() in the UnitOfWork
      This method takes the id of my deserialized Entity, that I want to
      merge, and looks if an Entity with that id is already in doctrine
      cache. If that is the case my deserialized Entity is merged with the
      one in the cache. So far so good. But I've got the Problem, that the
      Entity, which is in cache, is not initialized yet. It is not initialized because
      this Entity has a relation to another Entity that a used earlier in code.
      It's there but in uninitialized stat, because I did not access it yet.
      So when my deserialized Entity and the one from cache gets merged, some field are
      uninitialized (the id field, for example).

      I fixed the problem by adding this piece of code in line 1446 in the
      UnitOfWork class:
      if(! $managedCopy->_isInitialized_)

      { $managedCopy->__load(); }


        beberlei Benjamin Eberlei added a comment -

        Fixed and merged into 2.2 and 2.1

        beberlei Benjamin Eberlei added a comment - Fixed and merged into 2.2 and 2.1


          • Assignee:
            beberlei Benjamin Eberlei
            mrkanister MB
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: