Don't pass empty ids paramter, fix fatal
authoreileen <emcnaughton@wikimedia.org>
Thu, 16 Apr 2020 05:33:28 +0000 (17:33 +1200)
committereileen <emcnaughton@wikimedia.org>
Thu, 16 Apr 2020 05:33:28 +0000 (17:33 +1200)
CRM/Member/Form/MembershipView.php

index 85d207281f20e5467a53ffae306702c42fa4b9d6..6f4a71580e753abf07e9df3c4d89edb365e29b5d 100644 (file)
@@ -92,6 +92,9 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form {
    *   Create or delete.
    * @param array $owner
    *   Primary membership info (membership_id, contact_id, membership_type ...).
+   *
+   * @throws \CRM_Core_Exception
+   * @throws \CiviCRM_API3_Exception
    */
   public function relAction($action, $owner) {
     switch ($action) {
@@ -119,16 +122,14 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form {
           'skipStatusCal' => TRUE,
           'createActivity' => TRUE,
         ];
-        // @todo stop passing $ids here (we are only doing so because of passbyreference)
-        $ids = [];
-        CRM_Member_BAO_Membership::create($params, $ids);
+        CRM_Member_BAO_Membership::create($params);
         $relatedDisplayName = CRM_Contact_BAO_Contact::displayName($params['contact_id']);
         CRM_Core_Session::setStatus(ts('Related membership for %1 has been created.', [1 => $relatedDisplayName]),
           ts('Membership Added'), 'success');
         break;
 
       default:
-        CRM_Core_Error::fatal(ts("Invalid action specified in URL"));
+        throw new CRM_Core_Exception(ts('Invalid action specified in URL'));
     }
 
     // Redirect back to membership view page for the owner, without the relAction parameters