SoftDeleteable extension, 'soft-deleteable' query filter, expected behaviour, PR #2930
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:
https://github.com/doctrine-extensions/DoctrineExtensions/blob/ea1d37586b8e4bae2a815feb38b177894b12c44c/doc/softdeleteable.md?plain=1#L32
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.
Meanwhile I am convinced that PR #2930 is completely undesirable. See the further comments in the PR #2930.