-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce FilterCollection#restore method #10537
Introduce FilterCollection#restore method #10537
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. I've retargeted it to the 2.15.x branch because your change clearly isn't a bugfix.
I understand your motivation behind the PR and realize that the vocabulary used by the methods (enable/disable) might be confusing in your case. However, I believe that this confusion is getting even worse with your patch because it suggests that a filter can be in a state that is neither enabled nor disabled and that state is even the default one for every filter.
Another problem is that with your patch applied, the configuration of a disabled filter will be kept (because I might want to restore it one fine day) and I have no way to free the memory occupied by it. In most cases, this might not actually cause an issue, but I'd still like to avoid such situations if possible.
How about adding a new method to suspend a filter which explicitly tells the FilterCollection
that the caller intends to restore is later?
I like the idea of the suspend method. I'll make the change to not keep trace of a disabled filter and only keep trace of suspended filters. I just need to handle the following behavior:
Also, I wonder if the "getFilter($name)" method will need to work on suspended filters... |
Either that, or throw. But I think, we can implement it as you suggested: The suspended filter is deleted and a new one is created and enabled.
Good question. I'd say throw because currently you cannot disable what isn't enabled and I'd like to keep it that way. Then again, how would I remove a suspended filter? 🤔 Ideas?
Also a good question. Do we expect downstream code to assume that a given filter is active if |
Done
Done
With the current implementation, it's not possible... but I'm not sure it's needed.
The phpdoc say it only return enabled filters but doctrine code never use getFilter out of this class... Still, since I don't expect someone to do
I don't think there is a need to get a suspended filter so I didn't change the method. A suspended filter act like a disabled filter, you can't get it. The only diff is that you can restore it. |
Thanks. We should cover a few more scenarios with tests:
|
For all the others methods (and the getHash method) I should cover all the scenarios now. |
I believe this should be the default of enable() |
Maybe it should've been. How do we deal with apps that rely on calling disable followed by enable resets the parameters of a filter? |
From my PoV, the PR is okay as it is. Maybe @beberlei has a better idea how to address our concers regarding BC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can approve it, but I'd still like to get a response from @beberlei.
@derrabus @VincentLanglet maybe introduce a new method |
So, basically a Questions regarding that approach:
|
With these questions in mind, I find great the proposed implementation
|
Removing from the milestone until there is an agreement. |
I've pinged @beberlei on Slack. |
Lets go with restore then |
Thank you. And sorry for the delay, @VincentLanglet. |
Damn, I merged to the wrong branch. Reverted on 2.15.x and cherry-picked onto 2.16.x as 64ee76e. |
* Introduce FilterCollection#restore method * Add suspend method instead * Add more tests
Closes #10536
I just don't know if it's better to introduce a new method or it should be the default behavior of the
enable
method.