[PR #1577] EntityManager#merge() and EntityManager#detach() removal #9633

Closed
opened 2026-01-22 16:04:56 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/1577

State: closed
Merged: Yes


This PR simply attempts to get rid of EntityManager#merge() and EntityManager#detach() operations.

While merge and detach can be useful in contexts where entities are being serialized:

  • serializing entities is something we suggest NOT doing
  • the semantics really don't fit PHP
  • the merge operations are quite aggressive and cause a lot of issues
  • cascade merges not configured correctly = hell
  • EntityManager#clear() is a much better API for long-running and multi-threaded processes
  • the initial use-case around EntityManager#merge() was to merge data without further queries (when avoidable): the Second Level Cache now solves that problem in a more elegant way.

TODO:

  • update documentation
  • remove merge/detach mapping information
  • ~~~remove ObjectManager#detach() and ObjectManager#merge()~~~ (or provide empty implementation that throws, for now)
**Original Pull Request:** https://github.com/doctrine/orm/pull/1577 **State:** closed **Merged:** Yes --- This PR simply attempts to get rid of `EntityManager#merge()` and `EntityManager#detach()` operations. While `merge` and `detach` can be useful in contexts where entities are being serialized: - serializing entities is something we suggest NOT doing - the semantics really don't fit PHP - the merge operations are quite aggressive and cause a lot of issues - cascade merges not configured correctly = hell - `EntityManager#clear()` is a much better API for long-running and multi-threaded processes - the initial use-case around `EntityManager#merge()` was to merge data without further queries (when avoidable): the Second Level Cache now solves that problem in a more elegant way. TODO: * [x] update documentation * [x] remove merge/detach mapping information * [x] ~~~remove `ObjectManager#detach()` and `ObjectManager#merge()`~~~ (or provide empty implementation that throws, for now)
admin added the pull-request label 2026-01-22 16:04:56 +01:00
admin closed this issue 2026-01-22 16:04:56 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9633