Adding a default filter to discussions breaks a few things
Current Behavior
When adding a filter to the api/discussions endpoint that is activated by default (including when on /all and with default sort), then things like "Hide from All Discussions" in flarum/tags or the entire flarum/sticky logic just get ignored because there is an active filter.
I suppose the code that has been written makes sense because in most cases when you are on /all and have the default sort selected, there are no filters active. But in my use-case there is, so those extensions (tags & sticky) are broken. Maybe there are other things that are broken as well that I am not yet aware of...
As a reference, here are the lines of code that are making things break, because they are hard-coded to check if there is an active filter, and if there is the rest of the logic is skipped...
- https://github.com/flarum/framework/blob/05f80b7b83f6886eceef559752335aef09768e2a/extensions/sticky/src/PinStickiedDiscussionsToTop.php#L27
- https://github.com/flarum/framework/blob/379c06332a0789b892b0426b3eb8be24bd557db4/extensions/tags/src/Filter/HideHiddenTagsFromAllDiscussionsPage.php#L20
Steps to Reproduce
- Add a filter with an extension
- Make that this filter is active by default
- See broken sticky and tags behaviour
Expected Behavior
Tags and Sticky should work if there is a filter activated by default
Environment
- Flarum version: 1.5.0
- PHP version: 8.0.x
Possible Solution
A possible solution could be to add an extender that allows extensions to blacklist their filters so that they don't get counted when checking if there are active filters.
can you please give an example use case for such a filter? I'm thinking if a filter is meant to always be applied, why not make it a mutator instead? Or how do you decide when it is and isn't applied?
@SychO9 an example would be fof/discussion-language. Depending on the settings, there are cases where the discussions are filtered by the user language.