[2.x] fix(sticky): sticky discussions in hidden tags appear on all-discussions page#4492
Merged
[2.x] fix(sticky): sticky discussions in hidden tags appear on all-discussions page#4492
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sticky discussions tagged with a hidden tag were incorrectly appearing on the "All Discussions" page — a regression from 1.x behaviour.
Root cause:
PinStickiedDiscussionsToTopclones the raw query builder ($sticky = clone $query) to construct a UNION for the unread-sticky sort path. IfHideHiddenTagsFromAllDiscussionsPageran after that clone, thewhereNotInexclusion was never applied to the$stickysubquery, so hidden-tag discussions leaked through the UNION.Fix
Two complementary changes:
sticky/composer.json— declaresflarum-tagsas an optional dependency so tags always boots (and registers its mutator) before sticky, ensuring thewhereNotInis 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
is_hidden = true) and a sticky discussion in that tag to the existingListDiscussionsTestfixture.only_sticky_unread_discussionsenabled (the UNION path).Closes #4487