8000 [Serializer] Fatal error in denormalizeObject for Normalizers that do not implement DenormalizerInterface by linclark · Pull Request #7971 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Serializer] Fatal error in denormalizeObject for Normalizers that do not implement DenormalizerInterface #7971

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

Closed

Conversation

linclark
Copy link
Contributor
@linclark linclark commented May 7, 2013
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets 7971
License MIT
Doc PR

If there is a list of Normalizers, and only some of them implement DenormalizerInterface, then a call to deserialize() can result in a fatal error.

This is because denormalizeObject does not check that the Normalizer implements DenormalizerInterface before calling supportsDenormalization on it.

@lsmith77
Copy link
Contributor
lsmith77 commented May 8, 2013

+1 .. there are a few CS issues to fix though.

@@ -239,7 +239,8 @@ private function normalizeObject($object, $format = null, array $context = array
}

foreach ($this->normalizers as $normalizer) {
if ($normalizer->supportsNormalization($object, $format)) {
if ($normalizer instanceof NormalizerInterface
&& $normalizer->supportsNormalization($object, $format)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we format multi line if's like so:

if ($normalizer instanceof NormalizerInterface
    && $normalizer->supportsNormalization($object, $format)
) {

fabpot added a commit that referenced this pull request May 8, 2013
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #7971).

Discussion
----------

[Serializer] Fatal error in denormalizeObject for Normalizers that do not implement DenormalizerInterface

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | 7971
| License       | MIT
| Doc PR        |

If there is a list of Normalizers, and only some of them implement DenormalizerInterface, then a call to deserialize() can result in a fatal error.

This is because denormalizeObject does not check that the Normalizer implements DenormalizerInterface before calling supportsDenormalization on it.

Commits
-------

cacca2f [Serializer] Fixed fatal error in normalize/denormalizeObject.
fabpot added a commit that referenced this pull request May 8, 2013
@fabpot
Copy link
Member
fabpot commented May 8, 2013

Thanks @linclark for your contribution!

Some quick notes about our process:

  • I've merged this PR in the 2.2 branch as this is oldest branch that is still maintained;
  • I've fixed the CS (see e318759).

@fabpot fabpot closed this May 8, 2013
fabpot added a commit that referenced this pull request May 10, 2013
* 2.2:
  fixed CS
  Fixed XML syntax.
  Fixed parsing of leading blank lines in folded scalars. Closes #7989.
  [Form] Fixed a method name.
  Added a test case for Loader::import().
  Fixed Loader import
  [Console] Added dedicated testcase for HelperSet class
  [Serializer] fixed CS (refs #7971)
  Fixed fatal error in normalize/denormalizeObject.
  Fixed 2 namespaces

Conflicts:
	src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php
	src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0