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

Closed
opened 2026-01-22 14:04:18 +01:00 by admin · 9 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 9, 2013).

Originally assigned to: @Ocramius on GitHub.

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.

Originally created by @doctrinebot on GitHub (Jan 9, 2013). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user pschwisow: Following the changes for [DDC-1690](http://www.doctrine-project.org/jira/browse/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.
admin added the Bug label 2026-01-22 14:04:18 +01:00
admin closed this issue 2026-01-22 14:04:19 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 9, 2013):

Comment created by pschwisow:

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

@doctrinebot commented on GitHub (Jan 9, 2013): Comment created by pschwisow: Also, the returned proxy from $instanceA->getB() is in the entityStates array but not in the identity map
Author
Owner

@doctrinebot commented on GitHub (Jan 23, 2013):

Comment created by @ocramius:

Looks like this one is related to DDC-1734

@doctrinebot commented on GitHub (Jan 23, 2013): Comment created by @ocramius: Looks like this one is related to [DDC-1734](http://www.doctrine-project.org/jira/browse/DDC-1734)
Author
Owner

@doctrinebot commented on GitHub (Feb 23, 2013):

Comment created by @ocramius:

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.

@doctrinebot commented on GitHub (Feb 23, 2013): 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.
Author
Owner

@doctrinebot commented on GitHub (Feb 23, 2013):

Comment created by @beberlei:

A related Github Pull-Request [GH-589] was opened
https://github.com/doctrine/doctrine2/pull/589

@doctrinebot commented on GitHub (Feb 23, 2013): Comment created by @beberlei: A related Github Pull-Request [GH-589] was opened https://github.com/doctrine/doctrine2/pull/589
Author
Owner

@doctrinebot commented on GitHub (Feb 26, 2013):

Comment created by @beberlei:

A related Github Pull-Request [GH-589] was closed
https://github.com/doctrine/doctrine2/pull/589

@doctrinebot commented on GitHub (Feb 26, 2013): Comment created by @beberlei: A related Github Pull-Request [GH-589] was closed https://github.com/doctrine/doctrine2/pull/589
Author
Owner

@doctrinebot commented on GitHub (Feb 26, 2013):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Feb 26, 2013): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Apr 29, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-589] was closed:
https://github.com/doctrine/dbal/pull/589

@doctrinebot commented on GitHub (Apr 29, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-589] was closed: https://github.com/doctrine/dbal/pull/589
Author
Owner

@doctrinebot commented on GitHub (Nov 12, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1172] was assigned:
https://github.com/doctrine/doctrine2/pull/1172

@doctrinebot commented on GitHub (Nov 12, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-1172] was assigned: https://github.com/doctrine/doctrine2/pull/1172
Author
Owner

@doctrinebot commented on GitHub (Jan 16, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1172] was closed:
https://github.com/doctrine/doctrine2/pull/1172

@doctrinebot commented on GitHub (Jan 16, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1172] was closed: https://github.com/doctrine/doctrine2/pull/1172
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2807