User groups list does not work for hashed content types

Created on 13 November 2024, about 2 months ago

Problem/Motivation

In the database we have table "group_relationship_field_data" which is the data table for group content entities. In this table, we can see the columns type, group_type and plugin_id.

The pattern for the group membership type is usually -
. The type (column) is limited to 32 characters, and for example closed_challenge-group_membership (33 characters) is just too long.

Group includes a way to generate names that fit the limits imposed by Drupal core, and it does this consistently in its own code. However, this means that where a -
concatenation would exceed the limit, it instead converts it to 'group_content_type_' . md5($preferred_id) and truncates it. This is done in GroupRelationshipTypeStorage::getRelationshipTypeId. The problem is that our code is naively looking at the concatenation and doesn't handle the "too long" case, which is handled by the group module.

Steps to reproduce

  • Install Open Social
  • Go to /admin/group/types/add add group with machine name longer than 16 characters (like "group_with_long_name")
  • Add newly created group /group/add/group_with_long_name and become a member
  • Go to /user/1/groups and you will not see your newly created group on the list
  • Apply fix (and clear the cache)
  • Go to /user/1/groups and you will see your newly created group on the list

Proposed resolution

Do not filter by type but rather by plugin_id

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

12.4

Component

Code (back-end)

Created by

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

Comments & Activities

Production build 0.71.5 2024