mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
UnitOfWork pre update invoke causes some times fatal errors #4968
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 @ghost on GitHub (Jan 11, 2016).
Originally assigned to: @guilhermeblanco on GitHub.
I've the same problem like described in https://github.com/doctrine/doctrine2/issues/3468. Somehow the change set for the entity is gone while calling the commit function. I guess it will work if one changes the following line of code.
To use the method "getEntityChangeSet" to force to get an array. Because it does the same like before in a cleaner manner and one will always get an array back.
(
1697293591/lib/Doctrine/ORM/UnitOfWork.php (L1052))This is my first ticket creation for the doctrine2 project, I hope it will help to improve the project.
@Ocramius commented on GitHub (Jan 11, 2016):
@sr-amueller the initial issue ( #3468 ) was closed due to lack of tests: can you reproduce the issue in isolation?
@ghost commented on GitHub (Jan 11, 2016):
@Ocramius Not right now, but I will try to reproduce it the issue in isolation in the next few days.
@Ocramius commented on GitHub (Jan 11, 2016):
@sr-amueller thanks :-)
@Bencsi commented on GitHub (Jan 29, 2016):
In my case the problem was,
$em = $this->getDoctrine()->getManager();inside a try block, I moved this line above the try block, problem solved. :)@dontub commented on GitHub (May 11, 2017):
I think this might happen when
flush()is called a second time during a running flush. TheforeachinexecuteUpdates()iterates overentityUpdatesin the state when the loop was started so the currententityUpdatesandentityChangeSetsmight not contain the entity, anymore. In that case the following code at the beginning of the loop would be a possible solution:As commented in 86cde3a that fix leads to another error.
Aside: I'm wondering why the preUpdate event occurs during the flush whereas prePersist und preRemove occur immediately when
persist()orremove()is called.@apoorva-shah commented on GitHub (May 18, 2017):
I still got this error
Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::__construct() must be of the type array, null given, called in UnitOfWork.php on line 1060
In controller
Inside my service:
Please suggest.
@Ocramius commented on GitHub (May 18, 2017):
Flushing inside a flush operation is not supported, so that scenario is pretty much invalid.
@apoorva-shah commented on GitHub (May 18, 2017):
Hello @Ocramius thanks, but i did not understand
Flushing inside a flush operation is not supported, so that scenario is pretty much invalid.
Can you explain more? how to avoid this error?
@lcobucci commented on GitHub (May 18, 2017):
@apoorva-shah
EntityManager#flush()will commit the Unit of Work (UoW) which will then compute the changeset that needs to be applied to the persistence layer. Committing UoW changes in the middle of a commit causes inconsistencies and therefore is invalid.You can read http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html for more information.