schmittjoh / JMSSerializerBundle

Easily serialize, and deserialize data of any complexity (supports XML, JSON, YAML)
http://jmsyst.com/bundles/JMSSerializerBundle
MIT License
1.8k stars 311 forks source link

Symfony4 jms 3.10 LazyEventDispatcher injects a wrong container #867

Open lerminou opened 2 years ago

lerminou commented 2 years ago
Q A
Bug report? yes

After a migration sf3 => sf4 and a jms 2 =>3 upgrade, my project is not working anymore.

Steps required to reproduce the problem

  1. install jms serializer bundle 3.10
  2. run a request

Expected Result

Actual Result

JMS\Serializer\EventDispatcher\LazyEventDispatcher::__construct(): Argument #1 ($container) must be of type Symfony\Component\DependencyInjection\ContainerInterface, Symfony\Component\DependencyInjection\Argument\ServiceLocator given, called in /home/dev/app/cache/dev/ContainerKtlYnhv/srcKernelDevDebugContainer.php on line 13876

It's working if I comment these lines in the file : vendor/jms/serializer-bundle/DependencyInjection/Compiler/RegisterEventListenersAndSubscribersPass.php

if (class_exists(ServiceLocatorTagPass::class)) {
            $serviceLocator = ServiceLocatorTagPass::register($container, $listenerServices);
            $container->getDefinition('jms_serializer.event_dispatcher')->replaceArgument(0, $serviceLocator);
        }
goetas commented 2 years ago

it seems that you have updated the bundle, but what about jms/serializer library? which version are you using there?

lerminou commented 2 years ago

here are all my jms dependencies from the new composer.lock: "name": "jms/metadata", "version": "2.5.1", "name": "jms/serializer", "version": "3.14.0", "name": "jms/serializer-bundle", "version": "3.10.0", "name": "jms/translation-bundle", "version": "1.6.0", "name": "jms/i18n-routing-bundle", "version": "3.1.0",

and the symfony/dependency-injection package is in "version": "v4.4.27",