close
Skip to content

[2.x] fix(sticky): sticky discussions in hidden tags appear on all-discussions page#4492

Merged
imorland merged 1 commit into2.xfrom
im/fix-sticky-hidden-tags
Mar 22, 2026
Merged

[2.x] fix(sticky): sticky discussions in hidden tags appear on all-discussions page#4492
imorland merged 1 commit into2.xfrom
im/fix-sticky-hidden-tags

Conversation

@imorland
Copy link
Copy Markdown
Member

Summary

Sticky discussions tagged with a hidden tag were incorrectly appearing on the "All Discussions" page — a regression from 1.x behaviour.

Root cause: PinStickiedDiscussionsToTop clones the raw query builder ($sticky = clone $query) to construct a UNION for the unread-sticky sort path. If HideHiddenTagsFromAllDiscussionsPage ran after that clone, the whereNotIn exclusion was never applied to the $sticky subquery, so hidden-tag discussions leaked through the UNION.

Fix

Two complementary changes:

  • sticky/composer.json — declares flarum-tags as an optional dependency so tags always boots (and registers its mutator) before sticky, ensuring the whereNotIn is on the builder before the clone happens.
  • HideHiddenTagsFromAllDiscussionsPage — defensive belt-and-suspenders: after applying the filter to the main query, also applies it to any union queries already present on the builder, covering any future ordering edge cases.

Tests

  • Added a hidden tag (is_hidden = true) and a sticky discussion in that tag to the existing ListDiscussionsTest fixture.
  • Two new test cases: guest request and authenticated request with only_sticky_unread_discussions enabled (the UNION path).

Closes #4487

…ons page

PinStickiedDiscussionsToTop clones the raw query builder to create a
UNION for the unread-sticky path. If HideHiddenTagsFromAllDiscussionsPage
ran after the clone, the whereNotIn exclusion was never applied to the
$sticky subquery, letting hidden-tag discussions leak through via the UNION.

Two complementary fixes:
- Declare flarum-tags as an optional dependency of flarum-sticky so tags
  always boots (and registers its mutator) before sticky, ensuring the
  whereNotIn is on the builder before the clone happens.
- Defensively apply the whereNotIn to any existing union queries in
  HideHiddenTagsFromAllDiscussionsPage, covering cases where ordering
  cannot be guaranteed.

Closes #4487
@imorland imorland requested a review from a team as a code owner March 22, 2026 19:10
@imorland imorland changed the title fix(sticky): sticky discussions in hidden tags appear on all-discussions page [2.x] fix(sticky): sticky discussions in hidden tags appear on all-discussions page Mar 22, 2026
@imorland imorland added this to the 2.0.0-beta.8 milestone Mar 22, 2026
@imorland imorland merged commit 6ac318d into 2.x Mar 22, 2026
25 checks passed
@imorland imorland deleted the im/fix-sticky-hidden-tags branch March 22, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2.x] Sticky discussions from hidden tags appear on All Discussions page

1 participant