mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
UnitOfWork::executeUpdates iterates through an empty entityUpdates array #5803
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 @eugenmihailescu on GitHub (Dec 13, 2017).
Originally assigned to: @Majkl578 on GitHub.
Linux Gentoo 4.10.8
PHP 7.1.11 (cli) (built: Nov 3 2017 01:56:43) ( ZTS )
Doctrine VERSION = '2.5.13';
Symfony 3.4
Type error: Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::__construct() must be of the type array, null given, called in /vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 1064
I tracked down the problem (see UnitOfWork::executeUpdates function) and I've found that at the line 1053 if I would test the condition
count($this->entityUpdates) === 0it would return true because theentityUpdatesis really empty.Despite that the
foreachloop at line 1053 seems to want to iterate (which I assume is a very strange condition/bug, I never encountered that from PHP 5 to 7):Due to this condition the
$this->entityChangeSets[$oid]at line 1060 is evaluated to NULL which will throw the "Argument 3 passed..." exception mentioned earlier.I fixed that problem by adding the following code just inside the loop, at line 1054:
@kmwalke commented on GitHub (Dec 14, 2017):
Came here to report this exact issue. Thanks for writing it up!
@javabudd commented on GitHub (Dec 14, 2017):
Been hit by this issue a couple times, got around it by reworking our flush orders. This should ideally not fire the event if no changes have been made to the entity.
@Ocramius commented on GitHub (Dec 15, 2017):
Requires a test case
On 14 Dec 2017 17:16, "javabudd" notifications@github.com wrote:
@javabudd commented on GitHub (Dec 15, 2017):
It looks like the master branch has had this issue resolved for some time but is not in the latest tagged version 2.5.13
master - https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/UnitOfWork.php#L1097
2.5.13 - https://github.com/doctrine/doctrine2/blob/v2.5.13/lib/Doctrine/ORM/UnitOfWork.php#L1060
@Majkl578 commented on GitHub (Dec 16, 2017):
Probably fixed by
9b4c50e81e, but test case is still needed to prevent regression.@javabudd commented on GitHub (Dec 17, 2017):
I was able to reproduce the issue in a test which is fixed when running on master. Let me know if there is anything I need to alter or if you need a PR.
c08fd24d97@Majkl578 commented on GitHub (Dec 17, 2017):
@javabudd Can you please send a PR with the test against master? That would help us prevent regression in future. Thanks.
@eugenmihailescu commented on GitHub (Dec 18, 2017):
I can confirm that by installing doctrine/orm (dev-master
e1825e3) the initial problem I've described initially does not appear anymore. Thanks guys, you are awesome!@Majkl578 commented on GitHub (Dec 18, 2017):
Thanks for confirmation, closing then. Master will soon become 2.6.0, stay tuned. 😎