Details
-
Type:
Bug
-
Status: Done/Fixed
-
Priority:
Trivial
-
Resolution: Fixed/Completed
-
Affects Version/s: 2.2.0
-
Fix Version/s: 3.2.2
-
Component/s: Drupal Integration Modules
-
Labels:None
Description
If a drupal user has more than one membership record and one validates as expired and one validates as current, the resulting role will be set arbitrarily based on the status of the last membership record examined for that user. Should be: if any membership validates as current, set role; if no memberships are current, unset role.
The outer loop of `_civicrm_member_roles_sync()` causes processing of the rules in order, so if two rules affect the same Drupal role, then the processing of the second rule will arbitrarily overwrite the results of the first rule. So if rule #1 is for a "1 year voting membership" that is current and sets the Drupal role "Voting", and rule #2 is for a "2 year voting membership" that the same contact had but which has expired, the Drupal "Voting" role will not be set.
The attached diff fixes this for contacts as they login. The "manual sync" process has not yet been tested as my test data containing 100K contacts with memberships and PHP would run out of memory even when max_memory was set to 768M (perhaps the DAO memory leak issue?).