Hi,

since I have updated Drupal core from 8.1 to 8.2, there is an error on POST and PATCH content entity.

Error: Call to undefined method Drupal\Core\Entity\EntityTypeManager::getEntityTypeFromClass() in Drupal\serialization\Normalizer\EntityNormalizer->denormalize() (line 47 of core/modules/serialization/src/Normalizer/EntityNormalizer.php).

I don't know when $this->entityManager is changed to \Drupal\Entity\EntityTypeManager (backtrace joined)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

anty56 created an issue. See original summary.

Wim Leers’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)
Issue tags: -serialization, -REST

We have comprehensive test coverage now proving that POST and PATCH requests work in all possible combinations. So, what you're saying is unlikely, but not at all impossible.

You will have to provide steps to reproduce though, otherwise we couldn't possibly help you.

Wim Leers’s picture

Wim Leers’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
marral’s picture

Hello,
i have the same issue when updating from Drupal core 8.2 -> 8.4.4.
when i try to post an comment with the /comment resource i got this :

Error: Call to undefined method Drupal\Core\Entity\EntityTypeManager::getEntityTypeFromClass() in Drupal\serialization\Normalizer\EntityNormalizer->determineEntityTypeId() (line 38 of core/modules/serialization/src/Normalizer/FieldableEntityNormalizerTrait.php).
Drupal\serialization\Normalizer\EntityNormalizer->determineEntityTypeId('Drupal\comment\Entity\Comment', Array) (Line: 38)
Drupal\serialization\Normalizer\EntityNormalizer->denormalize(Array, 'Drupal\comment\Entity\Comment', 'json', Array) (Line: 264)
Symfony\Component\Serializer\Serializer->denormalizeObject(Array, 'Drupal\comment\Entity\Comment', 'json', Array) (Line: 174)
Symfony\Component\Serializer\Serializer->denormalize(Array, 'Drupal\comment\Entity\Comment', 'json', Array) (Line: 106)

marral’s picture

Version: 8.2.4 » 8.4.4
Status: Closed (cannot reproduce) » Active
marral’s picture

Assigned: Anthony Thomas » marral
Status: Active » Needs review
FileSize
2.46 KB

i created a patch that fix my issue, needs review and test.

Status: Needs review » Needs work

The last submitted patch, 7: issue_serialization_denormalize.patch, failed testing. View results

Berdir’s picture

Status: Needs work » Postponed (maintainer needs more info)

That's strange because \Drupal\serialization\Normalizer\EntityNormalizer definitely injects the entity manager not the entity type manager. Is it maybe using a subclass that actually injects a different service? What contributed modules are you using, what do you get when doing a get_class() in \EntityNormalizer->determineEntityTypeId or checking with the debugger?

Also, what other serialization related modules are you using?

Contrib modules have been too eager to update injected dependencies in subclasses before.

marral’s picture

hello @Berdir

yes it is strange, actually the EntityNormalizer inject the EntityManagerInterface, but it is using a trait FieldableEntityNormalizerTrait, this one is using : Drupal\Core\Entity\EntityTypeInterface. The determineEntityTypeId function is defined in this trait, when i did a get_class in this function i got this : Drupal\serialization\Normalizer\EntityNormalizer.

for serialization related modules i'm using the core one : Serialization and Hal.
ps: i got some custom normalizer that i defined, one of them (ContentEntityNormalizer) inject EntityTypeManagerInterface in the construct, i don't know if this custom normalizer are involved in this issue or not.

i hope this informations gonna help if u need more details feel free to ask.
thanks.

marral’s picture

Status: Postponed (maintainer needs more info) » Needs review
Berdir’s picture

> ps: i got some custom normalizer that i defined, one of them
(ContentEntityNormalizer) inject EntityTypeManagerInterface in the construct,
i don't know if this custom normalizer are involved in this issue or not.

That's exactly your problem. You can't do that. Yes, EntityManager is deprecated, but as long as the trait is still using EntityManager, you have to provide it what it needs.

Wim Leers’s picture

Thanks, Berdir, for providing support!

borisson_’s picture

I think #12 means that we can close this issue?

Berdir’s picture

Status: Needs review » Fixed

I think so too.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.