mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3218: Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::__construct() must be of the type array, null given #3986
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 @doctrinebot on GitHub (Jul 18, 2014).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user lyrixx:
{quote}
Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::**construct() must be of the type array, null given, called in /home/greg/dev/product/insight/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 1009 and defined
Stack trace:
[1] PHPUnit_Framework_Error: Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::__construct() must be of the type array, null given, called in /project/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 1009 and defined
at n/a
in /project/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php line 47
{quote}
I fails in this code
@doctrinebot commented on GitHub (Jul 18, 2014):
Comment created by @ocramius:
Requires a test case
@doctrinebot commented on GitHub (Aug 26, 2014):
Comment created by bocharsky.bw:
I have same bug when call flush() method from entity manager in my few event listeners in Symfony.
P.S. If I call flush() only from one listener - it works well, but when call flush() in first, and then in second - it fails. And it does not matter in which order listeners are called.
@doctrinebot commented on GitHub (Aug 26, 2014):
Comment created by lyrixx:
yeah, the bug occurs in the same circumstance as described by victor.
(sorry for the delay, and sorry to not provider a test case)
@doctrinebot commented on GitHub (Aug 26, 2014):
Comment created by stof:
Calling flush() inside a Doctrine listener is not a supported Doctrine usage. it means you are trying to nest several flushes inside each other, which can indeed break the unit of work
@doctrinebot commented on GitHub (Aug 26, 2014):
Comment created by lyrixx:
I refactored this part of our code base, to remove all flush from the listener. Everything works right now.
But I did not know this was not possible. (And it's not me the guy who created this ****** in our codebase ;))
@doctrinebot commented on GitHub (Aug 26, 2014):
Comment created by bocharsky.bw:
So, for example, if I use postUpdate Doctrine event to modify the entity after save them to DB, I can't save additional changes to DB again with flush() in my listener?
Is it will be fixed or it's a normal behavior of Doctrine?
@doctrinebot commented on GitHub (Feb 9, 2015):
Comment created by charlie_wasp:
I ran into the same issue, I wonder, what should I do?
if I use postUpdate Doctrine event to modify the entity after save them to DB, I can't save additional changes to DB again with flush() in my listener?
Is there an answer on this?
@doctrinebot commented on GitHub (Feb 9, 2015):
Comment created by @ocramius:
Flushing in a listener that acts during
EntityManagerInterface#flush()is disallowed.@doctrinebot commented on GitHub (Feb 9, 2015):
Comment created by @ocramius:
I'm marking this issue as incomplete: not reproducible without a test case.
@doctrinebot commented on GitHub (Feb 9, 2015):
Issue was closed with resolution "Incomplete"
@doctrinebot commented on GitHub (May 27, 2015):
Comment created by Wirone:
I'm facing this problem right now (doctrine/orm 2.5).
In my case:
preUpdate,postPersistandpostUpdatepreUpdatewe check if this is valid entity and old value of specified field differs from new value, if yes we internally store some array with data like below:postPersist(works ok) andpostUpdate(ContextErrorException) we're using custom logger, which has handler based on database, for storing changelog record. We create new entity, which has relation to modified entity. Exception rises when flushing changelog entity, which again dispatchespreUpdateon related entity withnull3rd argument.I can't post more code because it's company's property, but flow is described and clear (I think so).
@doctrinebot commented on GitHub (May 27, 2015):
Comment created by @ocramius:
That's not enough to reproduce the problem. From what I am thinking, this looks like a case where
flush()was called (again) in a listener (unsupported).I suggest you to write a test case, if this is still valid.
@doctrinebot commented on GitHub (May 27, 2015):
Comment created by Wirone:
Yes,
flush()was called inpostUpdate.. I've changed it to connection'sinsert()and now it works. Too bad it's unsupported (and not intuitive).@doctrinebot commented on GitHub (May 28, 2015):
Comment created by dalexandre:
Would be a good idea to throw a real exception when trying to flush in a flush; Making this mistake better known.
@JarJak commented on GitHub (May 17, 2016):
"Would be a good idea to throw a real exception when trying to flush in a flush; Making this mistake better known."
I came to the same issue today, throwing that exception would help a lot in debugging.
@galeaspablo commented on GitHub (Jul 15, 2016):
Yes there is, make the changes using DQL. If you use flush inside your listener, you'll get the flush process started again, and then more listeners. I'm guessing this recursion is why this isn't supported.
EDIT: You can also create an impediment for the flush to act recursively. By ensuring it's only run when a field has changed in PreUpdate. OR if you're using Symfony, use PostFlush as described in this SO - http://stackoverflow.com/questions/16904462/adding-additional-persist-calls-to-preupdate-call-in-symfony-2-1#answer-16906067
@Ocramius commented on GitHub (Jul 15, 2016):
Nested flushes are indeed not supported. If anybody wants to give a stab at a nesting check exception+guard, feel free to do so.
@Glideh commented on GitHub (Oct 26, 2016):
I have a
Logentity which tracks changes in anItementity.I need to know what changed each time
Itemis created, updated, deleted.I have an
ItemListenerentity listener taking care of myItem, I can't usePostFlushfrom here.How should I track the changes from my
ItemListener?@Glideh commented on GitHub (Oct 26, 2016):
It seems not possible with an EntityListener.
I used a standard listener with
onFlushto track all the updates.@riki137 commented on GitHub (Jun 5, 2017):
Same problem here. Any way to find out if we're already in a flush?