mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
ERROR - Notice: Undefined index: 000000004fc9e3630000000009549173 #6297
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 @sinner on GitHub (Sep 15, 2019).
Originally assigned to: @sinner on GitHub.
Bug Report
Summary
Current behavior
Hi Symfony Community! Thank you very much in advance.
I have an API that receives a CSV file to import some registers but this task is queued using Amazon SQS, so it's an asynchronous task made using the Symfony Console Component who is loading that data.
This command-line application made using the Symfony Console Component uses Doctrine to store all registers read from that CSV file, so when it starts the first register is loaded perfectly into my PostgreSQL (AWS-RDS) database, but after that first register the next tries aren't loaded to the database giving the following exception "Undefined index: 000000004fc9e3630000000009549173", just after executing flush here is a bit of the track-trace of the exception:
This address to us to put a dump into this class "/srv/api/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:677" to see what indexes were being generated, and actually we were reviewing that the index of the error wasn't part of the array of indexes array prepared to update/insert registers into the database and those indexes are generated from some Proxy/Entity classes that are generated dynamically and updated after we are executing the same command-line application.
Has somebody seen that error before? I've opened an issue because I didn't see this in other issues I've been reading, moreover, I've found another reference of the error in this page:
https://www.oipapio.com/question-537301
I've tried to solve all the warnings of relation references into my entity files but it didn't solve the problem. I hope you could help me.
How to reproduce
Trying to register several entity instances into a loop.
Expected behavior
The registers should be stored into the database after executing the flush method.
@lcobucci commented on GitHub (Sep 21, 2019):
@sinner it seems like you're manipulating objects that aren't in the UoW anymore. However, it's hard to say what happens without looking at the code. Also, have you tried to update to the latest ORM version (2.6.3)?
Would you please send us a failing test case that reproduces that behaviour via a PR? That would be very useful.
@linibou commented on GitHub (Sep 1, 2020):
I have the same kind of issue, i'm trying to copy an entity from a database to another. I clone the entity from the source entityManager an then i persist and flush into the destination entityManager. I manage to do the same thing without error on another entity. The entity on which there is no error has just one OneToOne relation whereas entity with error has multiple OneToMany.
I'm using symfony 4.4 with php 7.3.21 with these doctrine packages:
I don't know if this will help to understand but i'm glad to talk about it since i'm stuck on it ! 😃
Any help would be apprecied 😘
Regards
@SenseException commented on GitHub (Sep 1, 2020):
@linibou Would you like to take over of what @lcobucci asked for in his previous comment?
@linibou commented on GitHub (Sep 3, 2020):
Hello @SenseException thank you for your answer, while i worked on a failing test i saw that i had'nt the same error on all the objects that i used for testing. I have also an error of type "A new entity was found through the relationship ...."
The thing is that i don't even know if that i want to achieve is possible :-) Maybe you can answer me ...
I have an entity A linked to B on a database 1 an i want to clone it and save it to a database 2 but i want that my A clone on database 2 is linked to an existing B object on database 2 instead of creating a new one. All my attempts dont work, even if i retrieve B object on database 2 and i link it to new A object, at flush time it seems not be managed anymore and doctrine wants to create it instead of using existing one and obviously give me an error
A new entity was found through the relationship ...Basically i want to do that but doctrine wants to insert
$dest_obj_bbut it already exists. Does the thing that i want to do is possible ?@SenseException commented on GitHub (Sep 6, 2020):
I'm not sure if this is the same issue like initially mentioned, but I might need more information to be sure.
@linibou commented on GitHub (Sep 8, 2020):
thank you for your time, i have difficulties to understand what's happening here...
Notice: Undefined index: 000000002ee519f800000000526d95eei appreciate your help 🙂
@greg0ire commented on GitHub (Sep 8, 2020):
Relevant link:
717ef9106c/lib/Doctrine/ORM/UnitOfWork.php (L3010-L3013)@Fedik commented on GitHub (Sep 9, 2020):
when you doing cloning, you must reset ID also, if I right remember
upd: with ID I mean identifier, depend from your mapping, something like
@alcalyn commented on GitHub (Jul 16, 2021):
I have this same error in a doctrine entity listener, but only for testing.
For now, I used a workaround that fixes it: