[2.x] fix: send user slug, not username, for profile author filter - #4655
Merged
Conversation
The server-side `author` filter resolves values through the active user slug driver. When the driver is not the default `username` driver, sending `user.username()` no longer matches and the filter resolves to no IDs, producing empty discussion/post lists on user profiles. Send `user.slug()` instead so the value round-trips through whichever slug driver is configured. Closes #4603
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
When a non-default user slug driver is active (e.g.
IdWithDisplayName,id), the Discussions and Posts tabs on user profiles are empty, even though the count badges report the correct totals.Root cause:
DiscussionsUserPage,PostsUserPage, andSearchModalbuildfilter[author] = user.username(). The server-sideAuthorFilterresolves that value through the configured slug driver. UnderIdWithDisplayName, a plain username does not parse as<id>-<name>, so the filter throwsModelNotFoundException, the slug is silently skipped, and the query becomeswhereIn(..., []).The existing slug-driver test (
tests/integration/api/discussions/ListTest.php::author_filter_works_with_slug_driver) already pins the API contract:filter[author]takes whatever slug the active driver produces. This change brings the three frontend call sites in line with that contract.Test plan
IdWithDisplayNamedriver: own profile and another user's profile both populate Discussions and Posts tabs.iddriver: same.usernamedriver (default): no regression on own or other profiles./u/<slug>/posts: pre-fills the author filter correctly under each driver.?filter[author]=…query string matches the active driver's slug.Closes #4603