-
-
Notifications
You must be signed in to change notification settings - Fork 589
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
Fix DoctrineObjectConstructor deserialization with naming strategies #951
Conversation
@@ -87,11 +88,19 @@ public function construct(VisitorInterface $visitor, ClassMetadata $metadata, $d | |||
$identifierList = array(); | |||
|
|||
foreach ($classMetadata->getIdentifierFieldNames() as $name) { | |||
if (!array_key_exists($name, $data)) { | |||
if (method_exists($visitor, 'getNamingStrategy')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cant you check if $visitor instanceof AbstractVisitor
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i`m going to change this. but i think it will break the current master since the method "getNamingStrategy" was removed.
See: 9e3fd4d#diff-04059dbc4f97e37925ef18e828ce4f5b
i`m going to rework this merge request this Sunday.
i hope this pull request helps you to pinpoints the error from #806
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when this will be backported to master, things are easier since the name is now always part of metadata, it will be enough
$dataName = $metadata->propertyMetadata[$name]->serializedName;
Thanks a lot for the contribution. |
Sure MIT licence is fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great! thanks!
@re2bit do you think schmittjoh/JMSSerializerBundle#687 could be connected to your work done here? |
Use NamingStrategy to determine which array key in data should be used.
This should fix Error #806.
Problem Analysis:
While Object construction $data is used as Source for Doctrine Identifier Fields.
Since $data is either a raw array the names are not converted yet.