Add a check for when there is no membership id
authorTyrell Cook <tyrell@aghstrategies.com>
Wed, 8 Apr 2015 21:29:45 +0000 (17:29 -0400)
committerTyrell Cook <tyrell@aghstrategies.com>
Wed, 8 Apr 2015 21:29:45 +0000 (17:29 -0400)
CRM/Member/BAO/Membership.php

index 30d77c26d1d16422412f75f21afb4aee06cab512..bd9daf1219bf2bd1db6d5722fbbb2bab99c98245 100644 (file)
@@ -1056,6 +1056,17 @@ INNER JOIN  civicrm_membership_type type ON ( type.id = membership.membership_ty
         $membership['status_id'],
         'is_current_member', 'id'
       );
+      $ownerMemberId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership',
+        $membership['id'],
+        'owner_membership_id', 'id'
+      );
+      if ($ownerMemberId) {
+        $membership['id'] = $membership['membership_id'] = $ownerMemberId;
+        $membership['membership_contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership',
+          $membership['id'],
+          'contact_id', 'id'
+        );
+      }
       return $membership;
     }