CRM-4285 civicrm_member_roles doesn't support multiple memberships per user

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 3.2.2
    • 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.

        Attachments

          Activity

          [CRM-4285] civicrm_member_roles doesn't support multiple memberships per user
          Fen Labalme added a comment -

          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?).

          Fen Labalme added a comment -

          This patch is against v3.1.5 but can be applied to v3.2.0 also as there have been no changes to the file.

          Fen Labalme added a comment -

          I'm concerned that r29302 - that appears to be an attempted optimization - will break things by removing all roles from contacts that have no memberships. If a contact has no memberships, they may still have some static roles (like 'admin' for example).

          ref: https://fisheye2.atlassian.com/changelog/CiviCRM/?cs=29302

          Jim Taylor added a comment -

          I agree with Fen what's the logic behind that revision?

          Kurund Jalmi added a comment -

          Fen, we have fixed above mentioned issue, can you please confirm. You can get all the fixes from: http://issues.civicrm.org/jira/browse/CRM-4285?page=com.atlassian.jira.ext.fisheye:fisheye-issuepanel

          Sushant Paste added a comment -

          Tested in r29343.

            People

            • Assignee:
              Sushant Paste
              Reporter:
              Owen Rogers

              Dates

              • Created:
                Updated:
                Resolved: