[DDC-2230] Changes from DDC-1690 trigger a bug in entity merging Created: 09/Jan/13  Updated: 16/Jan/15  Resolved: 26/Feb/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3.2
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Critical
Reporter: Patrick Schwisow Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: None


Following the changes for DDC-1690, I encountered a serious bug in how EntityManager::merge(...) functions for entities that use NOTIFY change tracking. It's related to interaction between lazy loading and calls to addPropertyChangedListener().


  • EntityA has a One-To-One, lazy-load association to EntityB
  • EntityB implements NotifyPropertyChanged and uses change tracking policy "NOTIFY"

Steps to reproduce:

  1. $instanceA = $em->find('EntityA', $id)
  2. $em->clear()
  3. $instanceA = $em->merge($instanceA)
  4. $instanceA->getB() will return a proxy for B that is marked as initialized by contains no data

Workaround: Mark EntityB::addPropertyChangedListener(...) as 'final', so it doesn't get proxied and lazy loading is not triggered.

Comment by Patrick Schwisow [ 09/Jan/13 ]

Also, the returned proxy from $instanceA->getB() is in the entityStates array but not in the identity map

Comment by Marco Pivetta [ 23/Jan/13 ]

Looks like this one is related to DDC-1734

Comment by Marco Pivetta [ 23/Feb/13 ]

I implemented a fix at https://github.com/Ocramius/doctrine2/compare/hotfix;DDC-2230

Please let me know if that branch works for you: I will open a PR tomorrow.

Comment by Benjamin Eberlei [ 23/Feb/13 ]

A related Github Pull-Request [GH-589] was opened

Comment by Benjamin Eberlei [ 26/Feb/13 ]

A related Github Pull-Request [GH-589] was closed

Comment by Doctrine Bot [ 29/Apr/14 ]

A related Github Pull-Request [GH-589] was closed:

Comment by Doctrine Bot [ 12/Nov/14 ]

A related Github Pull-Request [GH-1172] was assigned:

Comment by Doctrine Bot [ 16/Jan/15 ]

A related Github Pull-Request [GH-1172] was closed:

Generated at Mon Nov 30 19:26:28 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.