-
-
Notifications
You must be signed in to change notification settings - Fork 554
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
[4.x] Fix user groups/roles querying #6131
[4.x] Fix user groups/roles querying #6131
Conversation
And force JsonContains comparison if values is an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a few change requests in individual comments. Happy for pushback.
Not sure how this fits in with Eloquent
This whole group query thing was clearly not very well thought out. 😞
Probably ideally we'd be able to treat it more like a relationship somehow. Or maybe do a similar thing to entries and the whereTaxonomy
method. We could get the user ids in the appropriate groups then have a whereIn('id', all the ids from the groups)
Asides from the individual comment replies.... Bigger picture, while this works, the It would need brought into the UserQueryBuilder so that it can be overridden by Eloquent. Something similar also would need implemented for roles. Do you have a preference? [edit] A further question - should the User hasRole method not also be checking the user's groups for roles assigned? |
@jasonvarga I've gone ahead and added It builds on the previous work so still uses the |
Please consider this PR - this documented functionality is broken in today's version of Statamic. |
# Conflicts: # src/Query/Scopes/Filters/UserGroup.php # src/Query/Scopes/Filters/UserRole.php # src/Stache/Stores/UsersStore.php
@edalzell I resolved the merge and pushed up the change. I didn't verify that the PR works yet, though. Feel free to try it out now. Maybe your issue was an incorrect merge. This PR is over a year old (sorry 😬) so it might just need more tweaking. |
Ok @edalzell @jasonvarga I've updated this to not require a relation to be set. You'll see in the eloquent UserQueryBuilder it now checks if a relation exists, and if not it performs a whereExists on the role_user or group_user table. This should cover off the default usage of people switching over from stache. If a dev wants to use a different approach for roles/groups (eg my PR) they would need to define the relationship on their user model. |
This one is quite breaking at the moment when using Eloquent for users. Can we expect this to be included in a hotfix release? |
It won't be a hotfix, it'll be a minor release. |
In the meantime you can composer patch it in to start using it. |
Anyone know when this will be released? |
It was released a while back |
This was released as part of v4.46.0. |
This PR updates the state store paths for user groups to use
->
rather than/
which resolves the errors in #6124 and follows up on the comments in #2498.It also updates the
getKeysWithWhere
method in theUserQueryBuilder
to have logic for roles and groups so that we do a comparison on their handle, rather than the entire object (which was failing). Not sure how this fits in with Eloquent... I might need to update this logic or handle it a different way?Fixes: #6124.
Fixes: #2498.
Fixes: #7578