JMSSerializerBundle icon indicating copy to clipboard operation
JMSSerializerBundle copied to clipboard

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

Open SDPrio opened this issue 9 months ago • 0 comments

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?

SDPrio avatar Nov 24 '23 07:11 SDPrio