Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag state loaded for first user in tag_user table instead of logged-in user in ShowTagController #4007

Closed
rafaucau opened this issue Jul 11, 2024 · 4 comments
Labels

Comments

@rafaucau
Copy link
Contributor

rafaucau commented Jul 11, 2024

Current Behavior

The tag state is being loaded for the first user in the database instead of the currently logged-in user. This issue affects extensions like Follow Tags that rely on eager loading of the tag state, causing them to not function correctly.
See: FriendsOfFlarum/follow-tags#72 (comment)

Steps to Reproduce

  1. Log in as a user other than the first user in the database.
  2. Observe the subscription state of tag on tag page.
  3. The tag state reflects the subscriptions of the first user in the database rather than the currently logged-in user.

Expected Behavior

The subscription state of tags should be loaded for the currently logged-in user, ensuring that extensions like Follow Tags work as expected.

Screenshots

Modified vendor/flarum/tags/src/Api/Controller/ShowTagController.php to display some info:
image

Environment

  • Flarum version: 1.8.5
  • PHP version: 8.3

Additional Context

This issue was initially identified while troubleshooting an issue with the Follow Tags (v1.2.3) extension.
The problem lies in this controller: ShowTagController

$tag->load($this->tags->getAuthorizedRelations($include, $actor));

@dsevillamartin
Copy link
Member

That seems right regarding the source - this is what Clockwork shows as the query coming with no user constraint

image
image

@rafaucau rafaucau changed the title Tag state loaded for first user in database instead of logged-in user in ShowTagController Tag state loaded for first user in tag_user table instead of logged-in user in ShowTagController Jul 14, 2024
@luceos
Copy link
Member

luceos commented Jul 15, 2024

Is either of you able to provide a patch to 1.x. I'm not sure this applies to 2.x, I'd have to check.

@rafaucau
Copy link
Contributor Author

rafaucau commented Jul 20, 2024

I could create a PR. Probably, it is necessary to modify SlugDriverInterface to accept additional query parameters for this to work.
Maybe @SychO9 has some hints?

@rafaucau
Copy link
Contributor Author

@luceos path provided in #4008 and #4009

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants