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:
- $instanceA = $em->find('EntityA', $id)
- $instanceA = $em->merge($instanceA)
- $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.