Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DefaultContext] ContextFactoryInterface aliases not updated when using defaultContext.id config #781

Closed
alexandre-abrioux opened this issue Dec 20, 2019 · 0 comments · Fixed by #782
Labels

Comments

@alexandre-abrioux
Copy link
Contributor

alexandre-abrioux commented Dec 20, 2019

Hi,

It looks like the creation of aliases to enable autowiring in 9f395cb introduced a issue.

When an app service is dependent of either SerializationContextFactoryInterface or DeserializationContextFactoryInterface and the app is using the according default_context.serialization.id or default_context.deserialization.id configuration option, the following ServiceNotFoundException exception triggers:

You have requested a non-existent service "jms_serializer.configured_serialization_context_factory".

This issue comes from the fact that when using the default_context.serialization.id option the jms_serializer.serialization_context_factory service alias is changed from the jms_serializer.configured_serialization_context_factory service to the service declared in the option, while the JMS\Serializer\ContextFactory\SerializationContextFactoryInterface service that got introduced in 9f395cb stays inchanged and still points to the jms_serializer.configured_serialization_context_factory service (a service that gets removed afterward):

if (isset($config['default_context'][$configKey]['id'])) {
$container->setAlias('jms_serializer.' . $configKey . '_context_factory', new Alias($config['default_context'][$configKey]['id'], true));
$container->removeDefinition($serviceId);
continue;
}

I created a test case that supports my claim (instructions in README):
https://github.com/alexandre-abrioux/JMSSerializerBundle-testDefaultContextID

Following the creation of this issue I will submit a pull request to try and fix it.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants