Discussion:
[doctrine-user] Association error: Notice: Undefined index: id in Doctrine/ORM/Persisters/BasicEntityPersister.php line 685
Sebastian Choren
2014-12-17 19:48:54 UTC
Permalink
Hello,

I'm using Doctrine v2.4.6 (with Symphony, if that matters) for a kind of
complex project. The issue I'm having is when running an importer (that
handles up to 200k rows per file, multiple files). My entities are
something like this:

Person
- id
- name

Address
- idaddress
- person (many-to-one Person)
- type (many-to-one Type)
- Address

Phone
- idphone
- person (many-to-one Person)
- type (many-to-one Type)
- phone

Type
- idtype
- description

(Entities are mapped with XML)

So, the importer process reads one file at a time (each file contains one
kind of entity, like Person.csv, Address.csv, etc) and creates entities,
that are then stored in APCCache. So far there's no access to DB.
The second step is to process those entities in the right order (first
Person, then Address, then Phone, etc). In this process, I check the DB to
see if it's an update or an insert. After that, I check that all relations
are contained by the EntityManager (since they were cached in APC,
relations such as Type might get detached and Doctrine tries to insert
them). Then I persist the object, and finally I flush the object, i.e.
$om->flush($object).

99% of the time this works, but with random Phones it throws this error:
Notice: Undefined index: id in
Doctrine/ORM/Persisters/BasicEntityPersister.php line 685.

The error rises when Doctrine tries to find the association info for the
object Person. Digging in the UnitOfWork, I noticed that the contents of
$uow->entityIdentifiers[spl_object_hash($person)] contains the association
information of Type instead of Person.

I really don't know what I can be doing wrong here. Specially since it
works most of the times, and the offending Entity varies from run to run.

What should I look for?

Thanks!
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+***@googlegroups.com.
To post to this group, send email to doctrine-***@googlegroups.com.
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.
Marco Pivetta
2014-12-17 21:16:23 UTC
Permalink
Looks like cache corruption: try switching to a different cache adapter and
see if the error still occurs.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/
Post by Sebastian Choren
Hello,
I'm using Doctrine v2.4.6 (with Symphony, if that matters) for a kind of
complex project. The issue I'm having is when running an importer (that
handles up to 200k rows per file, multiple files). My entities are
Person
- id
- name
Address
- idaddress
- person (many-to-one Person)
- type (many-to-one Type)
- Address
Phone
- idphone
- person (many-to-one Person)
- type (many-to-one Type)
- phone
Type
- idtype
- description
(Entities are mapped with XML)
So, the importer process reads one file at a time (each file contains one
kind of entity, like Person.csv, Address.csv, etc) and creates entities,
that are then stored in APCCache. So far there's no access to DB.
The second step is to process those entities in the right order (first
Person, then Address, then Phone, etc). In this process, I check the DB to
see if it's an update or an insert. After that, I check that all relations
are contained by the EntityManager (since they were cached in APC,
relations such as Type might get detached and Doctrine tries to insert
them). Then I persist the object, and finally I flush the object, i.e.
$om->flush($object).
Notice: Undefined index: id in
Doctrine/ORM/Persisters/BasicEntityPersister.php line 685.
The error rises when Doctrine tries to find the association info for the
object Person. Digging in the UnitOfWork, I noticed that the contents of
$uow->entityIdentifiers[spl_object_hash($person)] contains the association
information of Type instead of Person.
I really don't know what I can be doing wrong here. Specially since it
works most of the times, and the offending Entity varies from run to run.
What should I look for?
Thanks!
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+***@googlegroups.com.
To post to this group, send email to doctrine-***@googlegroups.com.
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.
Sebastian Choren
2014-12-17 21:23:55 UTC
Permalink
I'm not using cache for doctrine, I'm just using the doctrine cache adapter
to store arbitrary objects. I've already tried with Memcache an Redis, same
error.


--
Sebastian Choren
Skype: sebastian.choren
GTalk: ***@gmail.com
Google+: http://gplus.to/nerohc
Post by Marco Pivetta
Looks like cache corruption: try switching to a different cache adapter
and see if the error still occurs.
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/
Post by Sebastian Choren
Hello,
I'm using Doctrine v2.4.6 (with Symphony, if that matters) for a kind of
complex project. The issue I'm having is when running an importer (that
handles up to 200k rows per file, multiple files). My entities are
Person
- id
- name
Address
- idaddress
- person (many-to-one Person)
- type (many-to-one Type)
- Address
Phone
- idphone
- person (many-to-one Person)
- type (many-to-one Type)
- phone
Type
- idtype
- description
(Entities are mapped with XML)
So, the importer process reads one file at a time (each file contains one
kind of entity, like Person.csv, Address.csv, etc) and creates entities,
that are then stored in APCCache. So far there's no access to DB.
The second step is to process those entities in the right order (first
Person, then Address, then Phone, etc). In this process, I check the DB to
see if it's an update or an insert. After that, I check that all relations
are contained by the EntityManager (since they were cached in APC,
relations such as Type might get detached and Doctrine tries to insert
them). Then I persist the object, and finally I flush the object, i.e.
$om->flush($object).
Notice: Undefined index: id in
Doctrine/ORM/Persisters/BasicEntityPersister.php line 685.
The error rises when Doctrine tries to find the association info for the
object Person. Digging in the UnitOfWork, I noticed that the contents of
$uow->entityIdentifiers[spl_object_hash($person)] contains the association
information of Type instead of Person.
I really don't know what I can be doing wrong here. Specially since it
works most of the times, and the offending Entity varies from run to run.
What should I look for?
Thanks!
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the
Google Groups "doctrine-user" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/doctrine-user/DOpvWpvStV8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+***@googlegroups.com.
To post to this group, send email to doctrine-***@googlegroups.com.
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.
Loading...