Description
The PR #2930 removes entities from the object manager cache after soft-deletion in order to avoid spurious findBy() results which happily return cached entities. This is probably the desired behaviour if the 'soft-deleteable' query filter is not active (it is actually inactive by default). Please compare with the documentation:
DoctrineExtensions/doc/softdeleteable.md
Line 32 in ea1d375
I have tried to implement a test in order to clarify what I mean, see PR #2939
If the filter is actually switched off, e.g. like
$this->em->getFilters()->disable(self::SOFT_DELETEABLE_FILTER_NAME);
then with the already merged PR #2930 an entity is still cleared from the cache of the object manager on flush. Consequently, a subsequent $repo->find($entityId)
will then reload the entity from the database (as the soft-deleteable entity filter is not active). This is for one not necessary and also generates a new instance which even might break code which had the entity filter disabled on purpose.
So I am not completely convinced that the behaviour implemented in PR #2930 is desirable and I find it unexpected in a context where the entity filter is switched off. I think the cache shoot-down should only be performed if the soft-deleteable query filter is active for the respective entity classes.