amitaibu / og

A fork to work on OG8
https://github.com/Gizra/og
29 stars 16 forks source link

OG Roles are deleted when changing membership type #313

Closed krystalcode closed 8 years ago

krystalcode commented 8 years ago

In the Drupal 7 version of the module, the og_group function serves to not only create a membership but also change it. When the function is called with a different field defined than the one already used, the current membership is deleted and a new one is created. Responsible code within the og_group function:

elseif (!empty($field_name) && $og_membership->field_name != $field_name) {
  // Ungroup the current association, as it needs to change field.                                                                                                  
  og_ungroup($group_type, $gid, $entity_type, $id);
  $og_membership = FALSE;
}

The og_ungroup deletes the membership and the og_og_membership_delete hook deletes any associated roles.

However, I find the resulting behaviour unexpected and potentially buggy. I understand that by design the field used to store the membership also defines the membership type. But it does not define the roles that the user has in the group. If, for whatever reason I change the field/membership type, I do not expect the user to lose their current roles.

Could you clarify if this is by design, or an unintentional side effect? If the latter, I can submit a non-breaking PR, providing an extra argument in the og_group function that allows to preserve existing user roles.

krystalcode commented 8 years ago

Figured out this should go to the Gizra repository https://github.com/Gizra/og/issues/182