Skip to content

[Serializer] Fix serialization of items with groups across entities and discrimination map #27826

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

Merged

Conversation

sroze
Copy link
Contributor

@sroze sroze commented Jul 3, 2018

Q A
Branch? 4.1
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #27816, #27641
License MIT
Doc PR ø

I believe this approach is better than the one taken in #27816. At least, it's an alternative :)

@sroze
Copy link
Contributor Author

sroze commented Jul 3, 2018

Test failures are un-related.

@voodoo-dn
Copy link

This PR works well and fix my problem, thanks.

@voodoo-dn voodoo-dn mentioned this pull request Jul 3, 2018
@@ -142,11 +142,16 @@ protected function getAllowedAttributes($classOrObject, array $context, $attribu
return false;
}

if (null !== $this->classDiscriminatorResolver && null !== $discriminatorMapping = $this->classDiscriminatorResolver->getMappingForMappedObject($classOrObject)) {
$allowedAttributes[] = $attributesAsString ? $discriminatorMapping->getTypeProperty() : new AttributeMetadata($discriminatorMapping->getTypeProperty());
$class = is_object($classOrObject) ? \get_class($classOrObject) : $classOrObject;
Copy link
Member

Choose a reason for hiding this comment

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

is_object should be fully-qualified here, to benefit from the optimized opcode.

Copy link
Member

Choose a reason for hiding this comment

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

btw, shouldn't it go inside the if (null !== $this->classDiscriminatorResolver) { ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good points, updated 👍

@sroze sroze force-pushed the fix-serializer-with-groups-across-entities branch from 65e0370 to c648b93 Compare July 3, 2018 15:02
@nicolas-grekas nicolas-grekas added this to the 4.1 milestone Jul 3, 2018
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

(failures unrelated)
(sure we don't need more tests?)

@sroze
Copy link
Contributor Author

sroze commented Jul 5, 2018

@nicolas-grekas the fixture update covers the use-cases I think about so I'd say no 🤔

@nicolas-grekas
Copy link
Member

Thank you @sroze.

@nicolas-grekas nicolas-grekas merged commit c648b93 into symfony:4.1 Jul 9, 2018
nicolas-grekas added a commit that referenced this pull request Jul 9, 2018
… entities and discrimination map (sroze)

This PR was merged into the 4.1 branch.

Discussion
----------

[Serializer] Fix serialization of items with groups across entities and discrimination map

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27816, #27641
| License       | MIT
| Doc PR        | ø

I believe this approach is better than the one taken in #27816. At least, it's an alternative :)

Commits
-------

c648b93 Fix serialization of abstract items with groups across multiple entities
@fabpot fabpot mentioned this pull request Jul 23, 2018
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.

6 participants