Skip to content
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

Merged
merged 3 commits into from
May 25, 2018
Merged

Fix DoctrineObjectConstructor deserialization with naming strategies #951

merged 3 commits into from
May 25, 2018

Conversation

re2bit
Copy link

@re2bit re2bit commented May 17, 2018

Q A
Bug fix? yes
New feature? no
Doc updated no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #806 #734
License MIT

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.

@goetas goetas added this to the v1.12 milestone May 17, 2018
@goetas goetas added the bug label May 17, 2018
@@ -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')) {
Copy link
Collaborator

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?

Copy link
Author

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

Copy link
Collaborator

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;

@goetas
Copy link
Collaborator

goetas commented May 17, 2018

Thanks a lot for the contribution.
In case this gets merged are you ok with releasing it also as MIT license? (as we are migrating this project to a more permissive MIT license)

@goetas goetas changed the title Fix 1.11.0 Fix DoctrineObjectConstructor deserialization with naming strategies May 17, 2018
@re2bit
Copy link
Author

re2bit commented May 18, 2018

Sure MIT licence is fine.

Copy link
Collaborator

@goetas goetas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great! thanks!

@goetas
Copy link
Collaborator

goetas commented Oct 26, 2018

@re2bit do you think schmittjoh/JMSSerializerBundle#687 could be connected to your work done here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants