Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-20870

CIVICRM-209 CiviCRM API - Membership get with join on Contact with Group parameter returns incorrect results. Group parameter is ignored

    Details

    • Type: Improvement
    • Status: In Progress
    • Priority: Important
    • Resolution: Unresolved
    • Affects Version/s: 4.7.14, 4.7.21, 4.7.22
    • Fix Version/s: 4.7.23
    • Component/s: CiviCRM API
    • Labels:
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding
    • Verified?:
      No

      Description

      When using the CiviCRM API and Membership get with join on Contact with Group parameter returns incorrect results. Group parameter is ignored. This is the case if the Group ID is passed or the Group Reference.

      For example, Contact ID 2823 has a membership, but is not in the Administrators group. When the following API query is executed.

      $result = civicrm_api3('Membership', 'get', array(
        'sequential' => 1,
        'contact_id.group' => "Administrators",
        'contact_id' => 2823,
      ));
      

      The following results are returned.

      {
      "is_error": 0,
      "version": 3,
      "count": 1,
      "id": 832,
      "values": [
          {
              "id": "832",
              "contact_id": "2823",
              "membership_type_id": "9",
              "join_date": "2006-11-01",
              "start_date": "2016-07-01",
              "end_date": "2017-06-30",
              "status_id": "2",
              "is_test": "0",
              "is_pay_later": "0",
              "membership_name": "Concession",
              "relationship_name": "Child of"
          }
      ]
      

      This is incorrect as the Contact is not in the Administrators group.

      The correct response should be:

      {
      
          "is_error": 0,
          "version": 3,
          "count": 0,
          "values": []
      }
      

      The bug was found when using the CiviCRM API in code and verified using the CiviCRM API Explorer.

      Link to related MM discussion thread, https://chat.civicrm.org/civicrm/pl/mqzc6s1dzbbsimw69cyq6xdrky

      Agileware Reference CIVICRM-209 SUP-1808

        Attachments

          Activity

            People

            • Assignee:
              agileware Agileware
              Reporter:
              agileware Agileware
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: