DDC-119: Collection change tracking broken with NOTIFY policy #150

Closed
opened 2026-01-22 12:28:46 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 6, 2009).

Jira issue originally created by user romanb:

Looks like change tracking of collections together with the NOTIFY policy doesnt work well as collection updates are detected in _computeAssociationChanges. Perhaps the collection itself should inform the UnitOfWork directly?

Originally created by @doctrinebot on GitHub (Nov 6, 2009). Jira issue originally created by user romanb: Looks like change tracking of collections together with the NOTIFY policy doesnt work well as collection updates are detected in _computeAssociationChanges. Perhaps the collection itself should inform the UnitOfWork directly?
admin added the Bug label 2026-01-22 12:28:46 +01:00
admin closed this issue 2026-01-22 12:28:46 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 16, 2010):

Comment created by ksid:

Not sure if the issue is identical but seems at least related. Using NOTIFY change tracking with many-to-many bidirectional associations does not work. Objects added to the associations do not get persisted when calling EntityManager#flush.

Tested on r7404.

@doctrinebot commented on GitHub (Mar 16, 2010): Comment created by ksid: Not sure if the issue is identical but seems at least related. Using NOTIFY change tracking with many-to-many bidirectional associations does not work. Objects added to the associations do not get persisted when calling EntityManager#flush. Tested on r7404.
Author
Owner

@doctrinebot commented on GitHub (Jul 15, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jul 15, 2010): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Jul 16, 2010):

Comment created by mzach:

Dear Roman,

the line # 456 in UnitOfWork.php seems wrong to me:

            $isChangeTrackingNotify = isset($this->entityChangeSets[$oid]);

Shouldn't this only be set if the entity has

 @ChangeTrackingPolicy("NOTIFY") *

set in his class docBlock? The current behaviour now is to assign $changeset if changes exists, leaving the NOTIFY tracking policy out:

             $changeSet = $isChangeTrackingNotify ? $this->entityChangeSets[$oid] : array();

Because of this change, all our unit tests involving saving of entites break (basically, the whole application), which implement @postUpdate for logging purposes logging an own computed changeset.

@doctrinebot commented on GitHub (Jul 16, 2010): Comment created by mzach: Dear Roman, the line # 456 in UnitOfWork.php seems wrong to me: ``` $isChangeTrackingNotify = isset($this->entityChangeSets[$oid]); ``` Shouldn't this only be set if the entity has ``` @ChangeTrackingPolicy("NOTIFY") * ``` set in his class docBlock? The current behaviour now is to assign $changeset if changes exists, leaving the NOTIFY tracking policy out: ``` $changeSet = $isChangeTrackingNotify ? $this->entityChangeSets[$oid] : array(); ``` Because of this change, all our unit tests involving saving of entites break (basically, the whole application), which implement @postUpdate for logging purposes logging an own computed changeset.
Author
Owner

@doctrinebot commented on GitHub (Jul 16, 2010):

Comment created by romanb:

Hi,

you're right, I did that naivly because I thought the only case where an entity would already have a changeset on flush is with the NOTIFY policy. I did not think of custom use cases like yours. It is fixed now in master. My apologies. However, this still means your approach would be broken if you would use the NOTIFY policy right? That sounds like maybe there is potential to improve the approach you're currently using. If you're missing anything in the API or implementation that forbids a different approach feel free to raise some new JIRA issues so we can possibly improve the situation.

@doctrinebot commented on GitHub (Jul 16, 2010): Comment created by romanb: Hi, you're right, I did that naivly because I thought the only case where an entity would already have a changeset on flush is with the NOTIFY policy. I did not think of custom use cases like yours. It is fixed now in master. My apologies. However, this still means your approach would be broken if you would use the NOTIFY policy right? That sounds like maybe there is potential to improve the approach you're currently using. If you're missing anything in the API or implementation that forbids a different approach feel free to raise some new JIRA issues so we can possibly improve the situation.
Author
Owner

@doctrinebot commented on GitHub (Jul 16, 2010):

Comment created by mzach:

Thank you for fixing this real quick! Our current approach is to compute the changeset on @preUpdate and after a successful save write the changeset to the database in @postUpdate. This conflicted with the changes made, I will however look into it and see if it's feasible for us to implement another approach.

Once again, thanks for your reply and fix.

@doctrinebot commented on GitHub (Jul 16, 2010): Comment created by mzach: Thank you for fixing this real quick! Our current approach is to compute the changeset on @preUpdate and after a successful save write the changeset to the database in @postUpdate. This conflicted with the changes made, I will however look into it and see if it's feasible for us to implement another approach. Once again, thanks for your reply and fix.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#150