flarum / flarum/framework

Adding a default filter to discussions breaks a few things

Open
#3,644 2 comments 0 reactions 0 assignees View on GitHub
type/bug
Dominant language
PHP
Stars
6.7k
Forks
883
Avg merge
15h 16m
Merged PRs (30d)
73

Description

### 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

1. Add a filter with an extension
2. Make that this filter is active by default
3. 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.