Skip to content

fix #2158 - denormalize items without context and no Iri#2399

Closed
rpanfili wants to merge 1 commit into
api-platform:2.3from
rpanfili:2.3
Closed

fix #2158 - denormalize items without context and no Iri#2399
rpanfili wants to merge 1 commit into
api-platform:2.3from
rpanfili:2.3

Conversation

@rpanfili

Copy link
Copy Markdown
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #2158
License MIT
Doc PR -

This PR fix an issue when context does not contain the resource_class key.

It's the same behaviour of the AbstractItemNormalizer that inherit that option from the $class parameter before calling the parent::denormalize method. It actually has to be applied before try to update the object with updateObjectToPopulate method otherwise, if we are not using an IRI @id but only the object identifier, we got an

[ErrorException]
  Notice: Undefined index: resource_class

This is very useful using Symfony Messenger with Api-platform since otherwise Entity normalizer fails to denormalize object and we are not able to consume messages.

@soyuka

soyuka commented Dec 20, 2018

Copy link
Copy Markdown
Member

Does #2326 fix your issue?

@rpanfili

rpanfili commented Dec 20, 2018

Copy link
Copy Markdown
Author

Does #2326 fix your issue?

@soyuka in my specific use case (Messenger messages consumption) it works but that solution skips IRI composition (using the "guessed" class) and object population that can happens in updateObjectToPopulate as I tried to reproduce with the unit test case. Also the logger warning (maybe better a notice instead) it's a bit too much in my opinion since it's something that the parent class would normally manage without triggering any message.

@dunglas

dunglas commented Dec 20, 2018

Copy link
Copy Markdown
Member

Thanks for contributing @rpanfili! We finally merged #2326 that fixes the same issue.

@dunglas dunglas closed this Dec 20, 2018
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