onFlush event and $uow->computeChangeSets() in some cases erase entity properties #6246

Open
opened 2026-01-22 15:29:30 +01:00 by admin · 1 comment
Owner

Originally created by @forgie1 on GitHub (Jun 6, 2019).

Originally assigned to: @forgie1 on GitHub.

Bug Report

Q A
BC Break no
Version 2.6.3

Summary

If in onFlush event is changed newly created entity property to the same value as it was before = basically no change happend, but property was set to the same value. Flush throws these different errors, it depends if property was scalar, or related object(s):

a)
INSERT INTO table (param1, param2, id) VALUES (?, ?, ?)' with params [1000]
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

b)
SQLSTATE[HY093]: Invalid parameter number: no parameters were bound

Current behavior

parametes that have been set during onFlush event to the same value as they were originally (before onFlush event was invoked) are missing in changeset -> completely disappeared

How to reproduce

change new entity property in onFlush event to the same value as it was + call $uow->computeChangeSets()

in onFlush event:
$entity->getSize(); // 30
$entity->setSize(30);
$em->persist($entity);
$uow->computeChangeSets();

Expected behavior

Entity will be updated in DB with its proper values. Cahngeset will not be erased calling $uow->computeChangeSets() even if in onFlush event did set the same value to the entity property.

Originally created by @forgie1 on GitHub (Jun 6, 2019). Originally assigned to: @forgie1 on GitHub. ### Bug Report | Q | A |------------ | ------ | BC Break | no | Version | 2.6.3 #### Summary If in onFlush event is changed newly created entity property to the same value as it was before = basically no change happend, but property was set to the same value. Flush throws these different errors, it depends if property was scalar, or related object(s): a) INSERT INTO table (param1, param2, id) VALUES (?, ?, ?)' with params [1000] SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens b) SQLSTATE[HY093]: Invalid parameter number: no parameters were bound #### Current behavior parametes that have been set during onFlush event to the same value as they were originally (before onFlush event was invoked) are missing in changeset -> completely disappeared #### How to reproduce change new entity property in onFlush event to the same value as it was + call $uow->computeChangeSets() in onFlush event: $entity->getSize(); // 30 $entity->setSize(30); $em->persist($entity); $uow->computeChangeSets(); #### Expected behavior Entity will be updated in DB with its proper values. Cahngeset will not be erased calling $uow->computeChangeSets() even if in onFlush event did set the same value to the entity property.
admin added the BugMissing Tests labels 2026-01-22 15:29:30 +01:00
Author
Owner

@SenseException commented on GitHub (Jun 11, 2019):

Have you tried the described recomputeSingleEntityChangeSet() for changed primitives yet?

https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/events.html#onflush

@SenseException commented on GitHub (Jun 11, 2019): Have you tried the described `recomputeSingleEntityChangeSet()` for changed primitives yet? https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/events.html#onflush
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6246