Stop passing ids to membership::create from createRelatedMemberships
authoreileen <emcnaughton@wikimedia.org>
Thu, 16 Apr 2020 05:54:24 +0000 (17:54 +1200)
committereileen <emcnaughton@wikimedia.org>
Thu, 16 Apr 2020 05:54:24 +0000 (17:54 +1200)
We are passing in an empty array. Per the code comments there was concern that the array might NOT be empty after calling
create & that needed to be checked out. However, I just went through it & concluded that values in the ids var would
only ever be set if ids['membership'] was passed in - so if it goes in empty it will come out empty

CRM/Member/BAO/Membership.php

index 52b15d6a3afda6d0ae69140e0aac68424540cf49..ecfed40d572b09f0786775859b7defa10eeb49bc 100644 (file)
@@ -1480,15 +1480,13 @@ WHERE  civicrm_membership.contact_id = civicrm_contact.id
         $ids = [];
         if (($params['status_id'] == $deceasedStatusId) || ($params['status_id'] == $expiredStatusId)) {
           // related membership is not active so does not count towards maximum
-          // @todo stop passing empty $ids
-          CRM_Member_BAO_Membership::create($params, $ids);
+          CRM_Member_BAO_Membership::create($params);
         }
         else {
           // related membership already exists, so this is just an update
           if (isset($params['id'])) {
             if ($numRelatedAvailable > 0) {
-              // @todo stop passing empty $ids
-              CRM_Member_BAO_Membership::create($params, $ids);
+              CRM_Member_BAO_Membership::create($params);
               $numRelatedAvailable--;
             }
             else {
@@ -1507,8 +1505,7 @@ WHERE  civicrm_membership.contact_id = civicrm_contact.id
         if ($numRelatedAvailable <= 0) {
           break;
         }
-        // @todo stop passing $ids - at this point it may be set by reference from earlier calls to CRM_Member_BAO_Membership::create
-        CRM_Member_BAO_Membership::create($params, $ids);
+        CRM_Member_BAO_Membership::create($params);
         $numRelatedAvailable--;
       }
     }