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

Initializing a collection overwrites nulled field #11572

Open
insel-maz opened this issue Aug 13, 2024 · 0 comments
Open

Initializing a collection overwrites nulled field #11572

insel-maz opened this issue Aug 13, 2024 · 0 comments

Comments

@insel-maz
Copy link

insel-maz commented Aug 13, 2024

Bug Report

Q A
BC Break no?
Version 3.2.1 down to 2.x

Summary

When Doctrine fetches the entities for a PersistentCollection it overwrites the programmatically set null values in association fields for already managed (in the identity map) entities.

This happens by the if statement in

if (! $reflFieldValue || isset($this->hints[Query::HINT_REFRESH]) || $this->uow->isUninitializedObject($reflFieldValue)) {
.

Current behavior

The association field, which was just set to null by code, is overwritten with the persisted peer entity.

How to reproduce

In the following example there is a one-to-one association. One side gets set to null, but when a collection containing the entity is loaded, the field is restored with the peer entity.

https://github.com/insel-maz/doctrine-bug-collection-initialization-overwrites-field

Expected behavior

If an entity is already managed (in the identity map) Doctrine should not change the fields when fetching the database records for a PersistentCollection.

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