mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Calling FilterCollection::disable then FilterCollection::enable is losing the filter parameters.
#7110
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @VincentLanglet on GitHub (Feb 23, 2023).
Bug Report
Summary
I'm not sure if it can be considered as a bug or if it's the expected behavior.
Let's say I have a
deletedfilter.When using
I would have expected that the last query used the Filter with the passed parameter list.
But I saw nothing in the doc or in the unit test of the FilterCollection saying if
enableshould work in the current behavior or in arestoreway.My use case is that the two first line
are made in a Kernel request subscriber, and then in my project I either do
either do
for some special queries.
Expected behavior
Basically I would have expect the
enablemethod to work like arestoreone:I see different solution for this:
enablemethod should have work as arestoreone, I can do the PR.enablemethod works as expected, but adding arestoremethod is a nice idea, I can do the PR.disabledparameter to all my filter, and to changeby
I personally think the first or second options are the best ones.
I open to do a PR, just would like to know which solution is preferred (should it be a bugfix of
enableor a new featurerestore).@VincentLanglet commented on GitHub (Feb 23, 2023):
By looking at the
enablemethodThere is also the following behavior
This might be kinda confusing, I wonder if calling enable on a already enabled filter shouldn't trigger a deprecation and throw an exception in next major instead of doing nothing. 🤔
@mpdude commented on GitHub (Feb 26, 2023):
Personally, I find it not all too surprising:
enableenables the filter, if it is not already enableddisabledisables it, and there remain no traces of the filter on the particular query.We have to take care that we do not break BC, i. e. users who
disable()a filter currently have to assume/expect thatenablewill not bring back the old parameters, and we cannot change that.If I were you, I'd go with the additional
disabledflag that you can implement in your filter yourself, since that also makes you independent of a fix here and/or the version it will be released with.@VincentLanglet commented on GitHub (Feb 26, 2023):
Thanks for your answer.
Indeed, without any change in the doctrine code, I'll go with my "disabled" parameter.
But I still opened a PR to add a restore method with tests and docs. Do you think it can be something valuable to merge ?