DDC-2230: Changes from DDC-1690 trigger a bug in entity merging #2929

Closed
doctrinebot opened this Issue Jan 9, 2013 · 9 comments

2 participants

@doctrinebot

Jira issue originally created by user pschwisow:

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().

Scenario:

  • 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)

$em->clear()

$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.

@doctrinebot

Comment created by pschwisow:

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

@doctrinebot

Comment created by @ocramius:

Looks like this one is related to DDC-1734

@doctrinebot

Comment created by @ocramius:

I implemented a fix at https://github.com/Ocramius/doctrine2/compare/hotfix;[DDC-2230](http://www.doctrine-project.org/jira/browse/DDC-2230)

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

@doctrinebot

Comment created by @beberlei:

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

@doctrinebot

Comment created by @beberlei:

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

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-589] was closed:
doctrine/dbal#589

@doctrinebot

Comment created by @doctrinebot:

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

@doctrinebot

Comment created by @doctrinebot:

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

@Ocramius Ocramius was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.4 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment