CRM-20851 php notice (#10639)
authorMatthew Wire <devel@mrwire.co.uk>
Tue, 11 Jul 2017 20:45:20 +0000 (21:45 +0100)
committerEileen McNaughton <eileen@mcnaughty.com>
Tue, 11 Jul 2017 20:45:20 +0000 (08:45 +1200)
 Fix php notice when is_primary is not set

CRM/Contribute/Form/Task/Invoice.php
CRM/Core/BAO/Address.php
CRM/Member/Form/Membership.php

index 121bf65ec0fcac78f12f51aca6bae58307c82b7c..e9ed0e2e0bcdabb94d1b635f412c443fa3cd3b79 100644 (file)
@@ -287,11 +287,11 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task {
       // to get billing address if present
       $billingAddress = array();
       foreach ($addressDetails as $address) {
-        if ((isset($address['is_billing']) && $address['is_billing'] == 1) && (isset($address['is_primary']) && $address['is_primary'] == 1) && $address['contact_id'] == $contribution->contact_id) {
+        if (($address['is_billing'] == 1) && ($address['is_primary'] == 1) && ($address['contact_id'] == $contribution->contact_id)) {
           $billingAddress[$address['contact_id']] = $address;
           break;
         }
-        elseif (($address['is_billing'] == 0 && $address['is_primary'] == 1) || (isset($address['is_billing']) && $address['is_billing'] == 1) && $address['contact_id'] == $contribution->contact_id) {
+        elseif (($address['is_billing'] == 0 && $address['is_primary'] == 1) || ($address['is_billing'] == 1) && ($address['contact_id'] == $contribution->contact_id)) {
           $billingAddress[$address['contact_id']] = $address;
         }
       }
index 032ecee9a15ba4e511f67d2ef29f329e2e4949c0..df274fd788881aad36262d3492876001d99e85c4 100644 (file)
@@ -542,10 +542,10 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address {
 
       $addresses[$count] = $values;
 
-      //unset is_primary after first block. Due to some bug in earlier version
-      //there might be more than one primary blocks, hence unset is_primary other than first
+      //There should never be more than one primary blocks, hence set is_primary = 0 other than first
+      // Calling functions expect the key is_primary to be set, so do not unset it here!
       if ($count > 1) {
-        unset($addresses[$count]['is_primary']);
+        $addresses[$count]['is_primary'] = 0;
       }
 
       $count++;
index d4575a28626fe6aeb011229447b661093cb838db..b21338e75f9e1becd7a2c14ace77a874691803fa 100644 (file)
@@ -182,7 +182,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
       $contributionID = CRM_Member_BAO_Membership::getMembershipContributionId($this->_id);
       // check delete permission for contribution
       if ($this->_id && $contributionID && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
-        CRM_Core_Error::statusBounce(ts("This Membership is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
+        CRM_Core_Error::fatal(ts("This Membership is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
       }
     }