DDC-2726: EventSubscriber PreUpdate Error Bug? #3411

Closed
opened 2026-01-22 14:19:23 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Oct 6, 2013).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user nelfo:

Should this:

public function preUpdate(PreUpdateEventArgs $eventArgs)
{
    $entity = $eventArgs->getEntity();
    $em = $eventArgs->getEntityManager();
    $uow = $em->getUnitOfWork();

    if ($entity instanceof User) {
        if ($eventArgs->hasChangedField('finalStatus')) {
            $entity->setFinalStatusDate(new \DateTime('now'));
            $uow->recomputeSingleEntityChangeSet(
                $em->getClassMetadata("MyAdminBundle:User"),
                $entity
            );
        }
        if ($eventArgs->hasChangedField('membershipCode')) {
            $entity->setMembershipCodeDate(new \DateTime('now'));
            $uow->recomputeSingleEntityChangeSet(
                $em->getClassMetadata("MyAdminBundle:User"),
                $entity
            );
        }
    }
}

...result in this?

Catchable Fatal Error: Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::**construct() must be an array, null given, called in /var/www/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 995 and defined in /var/www/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php line 47

I'm just setting a time stamp for two updated values. Dumping the 3rd argument in PreUpdateEventArgs.php on line 47 reveals an array of changes. I'm not sure if this is a bug or if I'm performing this simple operation incorrectly.

Originally created by @doctrinebot on GitHub (Oct 6, 2013). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user nelfo: Should this: ``` public function preUpdate(PreUpdateEventArgs $eventArgs) { $entity = $eventArgs->getEntity(); $em = $eventArgs->getEntityManager(); $uow = $em->getUnitOfWork(); if ($entity instanceof User) { if ($eventArgs->hasChangedField('finalStatus')) { $entity->setFinalStatusDate(new \DateTime('now')); $uow->recomputeSingleEntityChangeSet( $em->getClassMetadata("MyAdminBundle:User"), $entity ); } if ($eventArgs->hasChangedField('membershipCode')) { $entity->setMembershipCodeDate(new \DateTime('now')); $uow->recomputeSingleEntityChangeSet( $em->getClassMetadata("MyAdminBundle:User"), $entity ); } } } ``` ...result in this? Catchable Fatal Error: Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::**construct() must be an array, null given, called in /var/www/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 995 and defined in /var/www/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php line 47 I'm just setting a time stamp for two updated values. Dumping the 3rd argument in PreUpdateEventArgs.php on line 47 reveals an array of changes. I'm not sure if this is a bug or if I'm performing this simple operation incorrectly.
admin added the Bug label 2026-01-22 14:19:23 +01:00
admin closed this issue 2026-01-22 14:19:23 +01:00
Author
Owner

@doctrinebot commented on GitHub (Oct 17, 2013):

Comment created by @ocramius:

Can you write an integration test around it? Looks like the changeset is removed in a particular edge case, but it's hard to figure it out without a test.

@doctrinebot commented on GitHub (Oct 17, 2013): Comment created by @ocramius: Can you write an integration test around it? Looks like the changeset is removed in a particular edge case, but it's hard to figure it out without a test.
Author
Owner

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

Comment created by florinutz:

here, solve it :P

@doctrinebot commented on GitHub (Sep 29, 2014): Comment created by florinutz: here, solve it :P
Author
Owner

@doctrinebot commented on GitHub (Oct 19, 2014):

Comment created by @ocramius:

Missing test case

@doctrinebot commented on GitHub (Oct 19, 2014): Comment created by @ocramius: Missing test case
Author
Owner

@doctrinebot commented on GitHub (Oct 19, 2014):

Issue was closed with resolution "Incomplete"

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

No dependencies set.

Reference: doctrine/archived-orm#3411