DDC-1584: updated fields won't persist in preUpdate listener #1987

Closed
opened 2026-01-22 13:36:16 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 6, 2012).

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user inori:

Right now any changes made in preUpdate() method are not persisted by default, only workaround is to make UnitOfWork recompute changeset again with something like this:

public function preUpdate(LifecycleEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();

// do the changes here..

$em = $eventArgs->getEntityManager();
$uow = $em->getUnitOfWork();
$meta = $em->getClassMetadata(get_class($entity));
$uow->recomputeSingleEntityChangeSet($meta, $entity);
}

(if code doesn't format correctly, here's a link: http://groups.google.com/group/symfony2/browse_thread/thread/b40323bcecdbbd9b/8b63f4950674abd5#8b63f4950674abd5 )

Originally created by @doctrinebot on GitHub (Jan 6, 2012). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user inori: Right now any changes made in preUpdate() method are not persisted by default, only workaround is to make UnitOfWork recompute changeset again with something like this: public function preUpdate(LifecycleEventArgs $eventArgs) { $entity = $eventArgs->getEntity(); // do the changes here.. $em = $eventArgs->getEntityManager(); $uow = $em->getUnitOfWork(); $meta = $em->getClassMetadata(get_class($entity)); $uow->recomputeSingleEntityChangeSet($meta, $entity); } (if code doesn't format correctly, here's a link: http://groups.google.com/group/symfony2/browse_thread/thread/b40323bcecdbbd9b/8b63f4950674abd5#8b63f4950674abd5 )
admin added the Improvement label 2026-01-22 13:36:16 +01:00
admin closed this issue 2026-01-22 13:36:24 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 13, 2012):

Comment created by @guilhermeblanco:

This is a known limitation and we marked this in our documentation.

@doctrinebot commented on GitHub (Jan 13, 2012): Comment created by @guilhermeblanco: This is a known limitation and we marked this in our documentation.
Author
Owner

@doctrinebot commented on GitHub (Jan 13, 2012):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Jan 13, 2012): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1987