Problem/Motivation
When I upgraded to the version 2.2 i've got this error (even on drush cr)
Fatal error: Uncaught Error: Class "Drupal\serialization\Normalizer\NormalizerBase" not found in /var/www/html/modules/contrib/duration_field/src/Normalizer/DateIntervalDataNormalizer.php:13
Stack trace:
#0 /var/www/html/vendor/composer/ClassLoader.php(576): include()
#1 /var/www/html/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}('/var/www/html/m...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('Drupal\\duration...')
#3 /var/www/html/modules/contrib/symfony_mailer/src/MailerPass.php(22): class_exists('Drupal\\duration...')
#4 /var/www/html/vendor/symfony/dependency-injection/Compiler/Compiler.php(73): Drupal\symfony_mailer\MailerPass->process(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
#5 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(825): Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
To avoid this error, I needed to enable the core module serialization.
Steps to reproduce
Use symfony mailer last version (I added it to the description because i saw it in my stack trace)
Use duration field last version
Proposed resolution
Add dependency to the module serialization
Issue fork duration_field-3593006
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
dkmishra commentedI tested this on Drupal 11 and was unable to reproduce the error. The module works without requiring the Serialization module to be enabled. Based on the stack trace, this issue may be related to the Symfony Mailer module rather than Duration Field itself. It would be helpful to know whether the problem can be reproduced on a clean Drupal 11 installation with only Duration Field enabled, without Symfony Mailer.
Comment #3
tichris59 commentedComment #4
tichris59 commentedHello @dkmishra, I just tested on a fresh install:
here my composer.json
duration field on drupal 13.3.10 is ok
just after enable symfony_mailer : KO
https://ibb.co/ks2GYHkJ
And the same bug if I enabled symfony_mailer and after duration_field.
Comment #5
dkmishra commented@tichris59, thanks for sharing above details. I was able to reproduce the issue.
The error appears to originate from
`web/modules/contrib/duration_field/src/Normalizer/DateIntervalDataNormalizer.php`.Around line 13, the file contains:During container compilation (for example, while enabling Symfony Mailer), Drupal scans enabled modules and attempts to load this normalizer. It then fails with:
Class "Drupal\serialization\Normalizer\NormalizerBase"not foundIt looks like the module relies on the serialization module but does not explicitly declare it as a dependency. It would make sense to add the following to duration_field.info.yml.
Comment #6
tichris59 commentedYes ! I made the change in this commit if you want: https://git.drupalcode.org/issue/duration_field-3593006/-/tree/8.x-2.x
Comment #7
dkmishra commentedThanks for making the change. If you could also create an MR, that would be great.
Comment #9
tichris59 commentedSure, it's done :) thanks for your time
Comment #10
dkmishra commentedThanks!
Comment #11
akashkumar07 commented@tichris59 sorry for this nitpicking.
Can you please add \n newline at the end of file duration_field.info.yml
Thanks!
Comment #12
tichris59 commented@akashkumar07 seems good
Comment #13
akashkumar07 commentedComment #14
akashkumar07 commentedThanks @tichris59
I have verified the changes and looking good.