Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.4.5
-
Fix Version/s: 4.5
-
Component/s: Drupal Integration Modules
-
Labels:
Description
The Drupal 7 version of CiviMember Roles Sync does not remove the relevant roles from a user when a membership is deleted.
I tracked this down to a query that was incorrectly ported from the Drupal 6 version to DBTNG for Drupal 7.
Drupal 6 version:
civicrm-4.4.5-drupal6 civicrm_member_roles.module, lines 509-512 (also 518-521):
if (is_array($rid))
{ $rid = implode(",", $rid); }db_query('DELETE FROM {users_roles} WHERE uid = ' . $uid . ' AND rid IN( ' . $rid . ' )');
This was ported to D7 as:
civicrm-4.4.5-drupal civicrm_member_roles.module, lines 528-531 (also 536-539):
if (is_array($rid)) { $rid = implode(",", $rid); }
db_delete('users_roles')>condition('uid', $uid)>condition('rid', $rid)->execute();
The problem with that is that the default operator for condition() is '=' if the supplied value is not an array. Which it isn't, because $rid has just been turned from an array to a comma-separated string. So, if $rid has more than one value, the condition becomes something like " rid = '1, 2, 3' ", which never matches because rid is an integer field.
The attached patch against 4.4.5-drupal (D7) fixes it for me.
Attachments
Issue Links
- has patch in
-
CRM-16932 In the absence of memberships, don't assume to remove all roles for which their are synchronisation rules
- Open