Fixes #18325: Ensure existing permission group users are maintained when editing a group#18326
Merged
snipe merged 2 commits intogrokability:developfrom Dec 19, 2025
Merged
Conversation
Member
|
I guess this seems fine, but all of our tests, we weren't dropping users in the first place. (See the piles of screencasts associated with those changes) |
snipe
requested changes
Dec 10, 2025
Member
snipe
left a comment
There was a problem hiding this comment.
Looks like we have some failing tests here.
Author
|
Ah, it looks like the And apologies -- it completely slipped my mind to run the test suite before submitting the original PR -- we are all green now, though 🙂 |
marcusmoore
approved these changes
Dec 18, 2025
Collaborator
marcusmoore
left a comment
There was a problem hiding this comment.
I tested this locally and it works 👍🏾
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.
Fixes #18325
The existing associated users for a permission group are being passed to the view as a Collection in
app/Http/Controllers/GroupsController.php:However, in the
groups.editview, the value of theusers_to_synchidden field is checking if the$associated_usersprop is an array. Since that prop is actually a Collection, this check fails, and the value defaults to an empty string even if there are users already associated with this group.Once the form is submitted, unless the users have been updated (i.e. users were added or removed to the group as part of the update -- I assume this is thanks to select2 pulling the existing members back in), all existing pivot records for the group are dropped from the
users_groupstable in the database when$group->users()->sync($associated_users)is called in the controller's update method since$associated_usersconsists solely of an empty string.The fix removes the conditional and uses Collection methods directly:
pluck('id')->implode(','). This works for both groups with no existing members (returning an empty string) and groups with existing members (returning a comma-separated list of user IDs), ensuring user-group associations are maintained when the group is updated.