Problem/Motivation
When a group's name is updated, the group's name does not also update on the user's subscriptions page.
It looks like the issue is in src/Form/UserSettings.php. On line 145, the code grabs the groupname from a group subscription table, but that groupname is likely the old group name.
// Retrieve stored group subscription configuration for this user.
$result = \Drupal::database()->select('group_subscription_groups', 'g');
$result->fields('g', ['uid', 'gid', 'groupname', 'subscription']);
$result->condition('g.uid', $userprofile);
$result->orderBy('groupname');
$result->allowRowCount = TRUE;
$group_settings = $result->execute()->fetchAll();
My theory is that we don't need the groupname column in the group_subscription_groups table — just for the reason I'm seeing. It's difficult to keep it synced with the groups_field_data table.
Steps to reproduce
- Create a new group called "Autobots."
- Your user's subscription page `/user/{user}/group_subscription` will have a setting for the group "Autobots".
- Change the group's name to "Deceptacons".
- The setting on your user subscription page will still read "Autobots."
Proposed resolution
In the long term, the groupname could be removed with a database update.
In the short term, you could join the groups_field_data table instead of relying on group_subscription_groups.groupname.
Remaining tasks
Will try to submit an MR for the short-term solution.
User interface changes
The correct group name will show in the user subscription page.
API changes
none
Data model changes
none ... yet.
Issue fork group_subscription-3333090
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jaydarnellThis is a really good catch and a substantial problem. I always appreciate it when someone else finds something I somehow completely overlooked. Thanks majorrobot. I won't likely have time to start on this until February. Please feel free to submit a PR if you have time to address?
Comment #4
majorrobot commented@JayDarnell, I've created a MR. Basically, instead of using the
group_subscriptions_groups.groupnamecolumn, I'm grabbing the group's actual label in the database call starting on line 146. There are other alternatives to this — like loading each group from the query results and getting the label that way — but they seem to be much messier and would involve a good amount of refactoring.As I mentioned in the issue description, it would be best to not have
group_subscriptions_groups.groupnameat all, but that is a more ambitious project.Comment #6
jaydarnellComment #7
jaydarnell