- Issue created by @joshuami
- π§πͺBelgium lobsterr
I tried to reproduce, without success.
1) When we remove the group it calls the next code:
public static function preDelete(EntityStorageInterface $storage, array $entities) { // Remove all relationships from these groups as well. foreach ($entities as $group) { assert($group instanceof GroupInterface); foreach ($group->getRelationships() as $relationship) { $relationship->delete(); } } }
It will remove all group relationships. What happens on my side and I see that the data also removed from group_relationship_field_data.
Also I noticed that GroupContentAccessControlHandler, it looks like you are using Group 2.0 and groupmedia 3.0. Right ? - π§πͺBelgium lobsterr
I checked also with Group 2.0 and Group media 3.0 and it works as expected
- πΊπΈUnited States joshuami Portland, OR
I'm seeing the issue with Group 3.3.4 and Group Media 4.0.3. (Should have included that in the original I.S.)
I would have expected
preDelete
to remove the media relationships as well, but it is not for this site. Let me do some additional testing and get back to you. - πΊπΈUnited States joshuami Portland, OR
Ah, my bad. I copied the error from the related issue. I'm updating the I.S. to reflect the actual error I saw:
TypeError: Drupal\group\Access\GroupAccessResult::allowedIfHasGroupPermissions(): Argument #1 ($group) must be of type Drupal\group\Entity\GroupInterface, null given, called in /var/www/html/docroot/modules/contrib/group/src/Plugin/Group/RelationHandlerDefault/AccessControl.php on line 190 in Drupal\group\Access\GroupAccessResult::allowedIfHasGroupPermissions() (line 57 of modules/contrib/group/src/Access/GroupAccessResult.php).
- πΊπΈUnited States joshuami Portland, OR
After a little more testing on a standard profile install of Drupal ^10 with Group ^3 and Group Media ^4, I'm not able to reproduce the issue. That likely means there is either a combination of permissions settings or perhaps some custom code.
Our standard group type doesn't give the "Admin" role every permission. We rely on a site wide role to be able to do full group management. Individual group admins can manage members, but we don't want them adding or editing relationships outside of the content forms so delete any existing relationships is disabled for all entity types so they won't see that UI.
We also have a custom module that does some syncing between relationships and a group entity reference field for more performant queries.
Perhaps one of those choices is creating an edge case where media is not properly deleted on
preDelete
.Sorry for the noise, but perhaps this will help someone else running into the error because a relationship is not properly deleted.