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

After an updated DoctrineObjectConstructor is automatically used instead of UnserializeObjectConstructor. How to change this back? #940

Open
SDPrio opened this issue Nov 24, 2023 · 0 comments

Comments

@SDPrio
Copy link

SDPrio commented Nov 24, 2023

Symfony 6.3
FOSRestBundle 3.6

JMSSerializerBundle + JMSSerializer updated 4.2.0 / 3.22.0 --> 5.3.1 / 3.28.0

After performing the updates via composers, deserialized JSON objects are now added to the the Doctrine EntityManager, thus becoming managed objects. This is not intended and was not the case before the update.

Upon investigation I found out, that this is because now during deserialization the DoctrineObjectConstructor is used instead of the UnserializeObjectConstructor as before.

I am not sure why this happened, since the update notes do not mention any BC. Issue #808 might be related. However, this issue referes to an older version and all related changed should already been included in versions 4.2.0 / 3.22.0 I used before the update. So, the update should not make any difference in this point, should it?

No other changed were made to the project or the config. When I switch back to versions 4.2.0 / 3.22.0 everything works fine again.

So, what is the reason for using DoctrineObjectConstructor and how can I change this back?

Disabling doctrine as object constructor in the config seems to solve the problem:

    jms_serializer:
        object_constructors:
            doctrine:
                enabled: false

However, I am not sure if this has some side effects. Since the docs do not state any BC I do not understand why this config change should be necessary. Is this a missing info in the docs, is there something wrong in my config? Is this the correct / intended way of keeping JMS from adding deserialized objects from being added to the EntityManager?

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

No branches or pull requests

1 participant