-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on entity clone for MappedSuperclass fields #5755
Comments
Can you check if |
Hello, Thanks for the feedback. Yes, it's working properly for my use case with the code
Regards, |
edhgoose
added a commit
to edhgoose/doctrine2
that referenced
this issue
Apr 11, 2016
…>getReflectionClass()->getProperties()' to ensure all fields are copied, and adds test to confirm behaviour
Ocramius
added a commit
that referenced
this issue
Sep 10, 2016
Ocramius
pushed a commit
that referenced
this issue
Sep 10, 2016
…ectionClass()->getProperties()' to ensure all fields are copied, and adds test to confirm behaviour
Handled in #5768 |
alexgurrola
pushed a commit
to Sitetheory-Archive/doctrine2
that referenced
this issue
Apr 13, 2017
…>getReflectionClass()->getProperties()' to ensure all fields are copied, and adds test to confirm behaviour
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
We get an error on cloning entity proxy following an upgrade from Doctrine 2.3 to 2.4 (but maybe relevant for 2.5 too).
The error is that fields declared as private on a MappedSuperClass are not cloned when a clone is done on a proxy entity of child class, only the protected fields of the MappedSuperClass are cloned.
This is a breaking change for us because it is only partially cloning entity and could have cause loss of data.
The cause is the usage of ClassMetadataInfo->getReflectionClass()->getProperties() rather than ClassMetadataInfo->reflFields in the cloning process.
I didn't find any existing issue or documentation about that, is it a known issue ?
Is there a clean solution existing to this issue please ?
Below the context information, the code analyse and the workaround solution.
Thanks in advance for your feedback on this issue.
Best regards,
Christophe
Context
changes done in composer.json:
Code analysis
in Doctrine 2.3, the clone method of a Proxy was simple
===> Cloning use the public property
ClassMetadataInfo->reflFields
in order to process the copy of fieldsin Doctrine 2.4, the clone method delegate the process to a callback method which comes that we can see in ProxyFactory.createCloner method
====> Cloning use
ClassMetadataInfo->getReflectionClass()->getProperties()
in order to process the copy of fieldsIn our use case,
ClassMetadataInfo->reflFields
was containing all the fields of the entity and its superclass, private+protected, butClassMetadataInfo->getReflectionClass()->getProperties()
returns only protected fields of the superclass.So it's only copying partially the entity.
Workaround
Declare all the fields of the
MappedSuperClass
as protected, rather than privateThe text was updated successfully, but these errors were encountered: