Deprecate EntityManager::flush with $entity argument #6621

Open
opened 2026-01-22 15:35:51 +01:00 by admin · 0 comments
Owner

Originally created by @beberlei on GitHub (Feb 6, 2021).

The method EntityManager::flush has an optional argument $entity (either accepting a single entity or array of entities) that when passed are the only set of entities considered in compute changeset operation. The idea originally was to allow more performant flush operations when a lot of entities are in the identity map.

However due to restrictions in how the UnitOfWork operates, it had to also "flush" other entities sometimes that were not passed to flush, making the operation inconsistent.

As such we decided to deprecate this approach to flushing and only allow a full flush for now.

Alternative: If you want to keep the set of entities small that flush operates on, you could decide to use the explicit change tracking policy for an entity instead of the implicit one. https://www.doctrine-project.org/projects/doctrine-orm/en/2.8/reference/change-tracking-policies.html

Originally created by @beberlei on GitHub (Feb 6, 2021). The method `EntityManager::flush` has an optional argument $entity (either accepting a single entity or array of entities) that when passed are the only set of entities considered in compute changeset operation. The idea originally was to allow more performant flush operations when a lot of entities are in the identity map. However due to restrictions in how the UnitOfWork operates, it had to also "flush" other entities sometimes that were not passed to `flush`, making the operation inconsistent. As such we decided to deprecate this approach to flushing and only allow a full flush for now. **Alternative**: If you want to keep the set of entities small that flush operates on, you could decide to use the explicit change tracking policy for an entity instead of the implicit one. https://www.doctrine-project.org/projects/doctrine-orm/en/2.8/reference/change-tracking-policies.html
admin added the Deprecation label 2026-01-22 15:35:51 +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#6621