Skip to content

SoftDeleteable extension, 'soft-deleteable' query filter, expected behaviour, PR #2930 #2940

Open
@rotdrop

Description

@rotdrop

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:

With SoftDeleteable there's one more step you need to do. You need to add the filter to your configuration:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions