mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-168: serialization/unserialization of ClassMetadata lose reflFields order causing insertSql statement to fail #208
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 (Nov 20, 2009).
Jira issue originally created by user rickdt:
This problem will be difficult to reproduce for you, but I isolated the exact cause of it.
To reproduce
I narrowed it down to a serialization issue.
When you serialize an MetadataInfo, you don't serialize reflFields.
When you unserizlize you regenerate this value using ReflectionClass
That sound's like a good optimization.
The problem is that somehow, the reflection class can return the fields not in the same order that they were at the initial creation of the MetadataInfo.
Because the insertSql value is not re-generated, it can be out of sync with the new fields order.
The solution :
Call something like MetadataInfoFactory::_generateStaticSql (whish is private but ...) at wakeup time.
@doctrinebot commented on GitHub (Nov 21, 2009):
Comment created by romanb:
Are you using composite keys anywhere?
The fact that reflFields is not serialized is not really an optimization but rather due to the fact that they simply can can not be serialized/unserialized properly.
We surely need some more concrete test case in order to reproduce this.
@doctrinebot commented on GitHub (Nov 23, 2009):
Comment created by rickdt:
I do not uses composite key anyware.
The field who change place is a foreign key.
EntityRevision extends Entity
EntityRevision.parent_entity : manyToOne entity
(the field parent_entity_id changes place during serialization)
What do you need to reproduce the case ? Just entitiy classes? a completely fuctionnal project? some kind of unit test ?
@doctrinebot commented on GitHub (Dec 5, 2009):
Comment created by romanb:
Hm. the order shouldnt even matter because insertSql only contains placeholders. Can you show the SQL INSERT that is failing? With parameters, if possible, and error message.
@doctrinebot commented on GitHub (Dec 6, 2009):
Comment created by rickdt:
For what I can remember, parameters are not bound in the right order which is causing an error like "field x could not be null"
I will post the real query on monday morning when I get back to work.
@doctrinebot commented on GitHub (Dec 7, 2009):
Comment created by rickdt:
Here is the real world example. I put the statement, the parameters, the error, and all the related entities.
@doctrinebot commented on GitHub (Dec 7, 2009):
Comment created by rickdt:
@doctrinebot commented on GitHub (Dec 7, 2009):
Comment created by @beberlei:
I could reproduce the issue and generated a failing test for this. We already discussed how this might be fixed.
@doctrinebot commented on GitHub (Dec 7, 2009):
Comment created by rickdt:
This is a very good news !
@doctrinebot commented on GitHub (Dec 17, 2009):
Comment created by romanb:
Should be fixed now.
@doctrinebot commented on GitHub (Dec 17, 2009):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Dec 17, 2009):
Comment created by rickdt:
Resolution confirmed.
Thank your for your great work !