Hi,

I want to report a bug when using the Metatag module.

- I do a clean install of Drupal 8.
- When I use composer to install Metatag and drush to enable Metatag there is no problem
- When I try to install other modules like admin_toolbar and devel I run in to this error:

Fatal error: Class 'Drupal\serialization\Normalizer\NormalizerBase' not found in /path/modules/contrib/metatag/src/Normalizer/FieldItemNormalizer.php on line 10
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Class 'Drupal\serialization\Normalizer\NormalizerBase' not
found in /path/modules/contrib/metatag/src/Normalizer/FieldItemNormalizer.php,
line 10

When I uninstall Metatag the problems are gone, when I try to enable Metatag again the error appears again.

I found one issue also talking about this Normalize problem but that was when using the JSON api module. And I'm not using this so I was wondering what I can do to solve this problem.

Comments

zebda created an issue. See original summary.

DamienMcKenna’s picture

We're also discussing the problem in #2901253: Add normalization support for metatag module.

The weird thing is that the system shouldn't be trying to load normalizer plugins unless necessary. I honestly wonder if there's a bug in Devel.

Can you please let me know what versions of Drupal core and Devel you're using? Thanks.

zebda’s picture

Hi,

Thanks for your reply. Yes I found that string but since I'm not using the JSON Api I wanted to mention it anyway.
I'm using Drupal 8.3.7 and Devel 8.x-1.0

Keep me updated.
Joost

attheshow’s picture

I was receiving normalize errors trying to get JSON API output while having Metatag installed (see: https://www.drupal.org/node/2903261). I just wanted to make everyone aware. Thanks!

DamienMcKenna’s picture

Status: Active » Postponed (maintainer needs more info)

I think there are two separate problems here and they're getting confused.

The problem with the Devel module should be fixed thanks to 1.0 being released.

Is there anything left to fix with this?

Blanca.Esqueda’s picture

Status: Postponed (maintainer needs more info) » Active
Related issues: +#2908064: Metatags supported?

Hi,

Metatag didn't implement their FieldItemNormalizer correctly. The normalize() function should return an instance of the $supportedInterfaceOrClass which is Drupal\metatag\Plugin\Field\FieldType\MetatagFieldItem, but instead a Translation object is returned;
Implementation fail
Instead of just saying normalization is not supported, they should've implemented the method made for that exact purpose;

/**
   * {@inheritDoc}
   */
  public function supportsNormalization($data, $format = NULL){
    return false;
  }

As per amenzou and webfaqtory comments on the following discussion:
https://www.drupal.org/project/content_sync/issues/2908064#comment-12518866

Regards,
Blanca

mlncn’s picture

Version: 8.x-1.2 » 8.x-1.8
Priority: Normal » Major

I think we might be running into some variant of this; the error we're getting is that class 'Drupal\metatag\Normalizer\FieldItemNormalizer itself is not found.

AH01071: Got error 'PHP message: Error: Class 'Drupal\\metatag\\Normalizer\\FieldItemNormalizer' not found in /site/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 258 #0 /site/web/core/lib/Drupal/Component/DependencyInjection/Container.php(495): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'private__fRkTna...')\n#1 /site/web/core/lib/Drupal/Component/DependencyInjection/Container.php(508): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters(Array)\n#2 /site/web/core/lib/Drupal/Component/DependencyInjection/Container.php(230): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters(Array)\n#3 /site/web/core/lib/Drupal/Component/DependencyInjection/Container.php(171): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'serializer')\n#4 /site/web/core/lib/Drupal/Component/DependencyInjection/Co...\n'

This is happening after an update of config_normalizer from 8.x-1.0-alpha4 to 8.x-1.0-alpha5, and it completely breaks any use of Drush and even core/update.php.

mlncn’s picture

Priority: Major » Normal

... adding the code Blanca.Esqueda recommended to modules/contrib/metatag/src/Normalizer/MetatagNormalizer.php and doing drush cr fixed it for me.

Unfortunately, removing the code didn't reproduce the problem, and now i'm sitting here shocked that there's a possibility i didn't try reloading the cache before editing the code. Dropping back to normal priority but i think there may still be something here for Metatag to fix.

DamienMcKenna’s picture

Let's focus our efforts on #2945817: Support JSON API, REST, GraphQL and custom normalizations via new computed field and create additional issues if further work is needed after that.