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

Fix user singleton when an argument is passed. #9572

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

driusan
Copy link
Collaborator

@driusan driusan commented Feb 19, 2025

User::singleton currently always returns the logged in user. If the $username argument is passed, it still returns the logged in user instead of the user requested.

This updates the singleton so that it's possible to use it to get references to other users.

User::singleton currently always returns the logged in user.
If the $username argument is passed, it still returns the logged
in user instead of the user requested.

This updates the singleton so that it's possible to use it to
get references to other users.
@driusan driusan added Category: Bug PR or issue that aims to report or fix a bug Language: PHP PR or issue that update PHP code Difficulty: Simple PR or issue that should be easy to implement, review, or test labels Feb 19, 2025
@ridz1208
Copy link
Collaborator

@driusan I think this problem might be on 26 as well? can you fix it there if its the case please? it affects projects currently on 26

@driusan
Copy link
Collaborator Author

driusan commented Feb 19, 2025

@ridz1208 I think the problem goes back to the beginning of time. What is the reasoning to put this on 26? I found this by trying to write new code. I don't think it affects any existing code since it's always called without an argument.

@ridz1208
Copy link
Collaborator

@driusan I thought it broke recently, I tried using the singleton for a CBIG feature and realised it only ever returns the current user. I ended up using the factory directly. I figured it's a bugfix it could got to 26 but if its been like that ofrever its fine to just got o main

@driusan
Copy link
Collaborator Author

driusan commented Feb 19, 2025

I think that's the case for all existing code--anyone who tried using it realized it didn't work and used factory directly. That's why I sent this to main: as far as I can tell it doesn't fix any user-facing bugs since all current code has a workaround, but it makes it possible to use it in new code and is less surprising to anyone who tries to do it.

Copy link
Collaborator

@ridz1208 ridz1208 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate it but okai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Bug PR or issue that aims to report or fix a bug Difficulty: Simple PR or issue that should be easy to implement, review, or test Language: PHP PR or issue that update PHP code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants