[PR #1172] Don't initialize detached proxies when merging them. #9229

Open
opened 2026-01-22 16:03:38 +01:00 by admin · 0 comments
Owner

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

State: closed
Merged: No


Ticket DDC-1392 fixed an issue where uninitialized proxies could not be merged
because the merge routine couldn't get the identifier from them. The soution
was to initialize the proxy.
Ticket DDC-1734 fixed the merging of unserialized uninitialized proxies by
resetting their internals, so these proxies were able to initialize, as required
by the fix for DDC-1392.

Somehow, in the meanwhile, the fix for DDC-1392 is not needed anymore:
reverting the patch will not break the associated test (but it does break the
test for DDC-1734). This means it is not needed anymore to initialize the proxy
when merging.

Uninitialized proxies that get merged should not be loaded at all. Since they
are not initialized, the entity data for sure hasn't changed, so it can be
safely ignored. Actually, the only thing the data is needed for while merging,
is to copy it into the managed entity, but that one is already supposed to be
up to date. By not initializing the proxy, a potential database roundtrip is
saved, and the fix for DDC-1734 is not needed anymore.

Besides optimizing the merge, this patch also solves an issue with merging.
Currently, when a detached uninitialized proxy is merged while there is already a
corresponding managed entity (proxy or not), the ORM returns a blank entity
instead of returning the already managed entity. This patch makes sure that
already existing managed entities are re-used.

**Original Pull Request:** https://github.com/doctrine/orm/pull/1172 **State:** closed **Merged:** No --- Ticket DDC-1392 fixed an issue where uninitialized proxies could not be merged because the merge routine couldn't get the identifier from them. The soution was to initialize the proxy. Ticket DDC-1734 fixed the merging of _unserialized_ uninitialized proxies by resetting their internals, so these proxies were able to initialize, as required by the fix for DDC-1392. Somehow, in the meanwhile, the fix for DDC-1392 is not needed anymore: reverting the patch will not break the associated test (but it does break the test for DDC-1734). This means it is not needed anymore to initialize the proxy when merging. Uninitialized proxies that get merged should not be loaded at all. Since they are not initialized, the entity data for sure hasn't changed, so it can be safely ignored. Actually, the only thing the data is needed for while merging, is to copy it into the managed entity, but that one is already supposed to be up to date. By not initializing the proxy, a potential database roundtrip is saved, and the fix for DDC-1734 is not needed anymore. Besides optimizing the merge, this patch also solves an issue with merging. Currently, when a detached uninitialized proxy is merged while there is already a corresponding managed entity (proxy or not), the ORM returns a blank entity instead of returning the already managed entity. This patch makes sure that already existing managed entities are re-used.
admin added the pull-request label 2026-01-22 16:03:38 +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#9229