mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1775: Notify strategy listener is not attached for new entities #2233
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Apr 11, 2012).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user deatheriam:
New entities with Notify strategy for changes and with GeneratedValue(strategy="AUTO") never get the onPropertyChanged listener attached to them. That happens because of the logic in the UOW::scheduleForInsert($entity) method. The last condition in it "isset($this->entityIdentifiers[$oid])" is never true because the identifier is not set and therefore the code that attaches the PropertyChangedListener in addToIdentityMap is never run.
@doctrinebot commented on GitHub (May 23, 2012):
Comment created by @guilhermeblanco:
This is intentional to me.
According to code and documentation, PropertyChanged is supposed to operate over updates, never over inserts.
I experimented changing the code to also notify about changed during new and the consequences were very drastic. Internally, propertyChanged creates entityChangesets that implies an UPDATE.
Marking ticket as won't fix.
@doctrinebot commented on GitHub (May 24, 2012):
Comment created by deatheriam:
In that case the Notify strategy is partially broken:
Category entity:
OnFlush event handler:
Code that uses the entity:
If there is no explicit call to the addPropertyChangedListener method, the caption field gets saved but the $addedAt remains null after flush. The entity does not have the attached listener so UnitOfWork does not know anything about the update that happened in the OnFlush event, and the recomputeSingleEntityChangeSet method skips entities with Notify strategy.
@doctrinebot commented on GitHub (May 27, 2012):
Comment created by @beberlei:
Changing computeScheduleInsertsChangeSets() would solve this, but it would also mean that the notifier gets injected more than once.
I think injecting in scheduleForInsert() is ok, but we have to look at potential problems also
@doctrinebot commented on GitHub (Jul 7, 2012):
Comment created by @beberlei:
Fixed
@doctrinebot commented on GitHub (Jul 7, 2012):
Issue was closed with resolution "Fixed"