Group names don't update on user subscriptions page

Created on 12 January 2023, over 1 year ago
Updated 3 February 2023, over 1 year ago

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

  1. Create a new group called "Autobots."
  2. Your user's subscription page `/user/{user}/group_subscription` will have a setting for the group "Autobots".
  3. Change the group's name to "Deceptacons".
  4. 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.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States majorrobot

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • @majorrobot opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States majorrobot

    @JayDarnell, I've created a MR. Basically, instead of using the group_subscriptions_groups.groupname column, 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.groupname at all, but that is a more ambitious project.

  • Status changed to Fixed over 1 year ago
  • πŸ‡¨πŸ‡¦Canada JayDarnell Guelph, Ontario
  • Status changed to Fixed over 1 year ago
  • πŸ‡¨πŸ‡¦Canada JayDarnell Guelph, Ontario
Production build 0.69.0 2024