From 96ca83769b06706df5204b74e28857f37d547623 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Tue, 11 Jul 2017 21:45:20 +0100 Subject: [PATCH] CRM-20851 php notice (#10639) Fix php notice when is_primary is not set --- CRM/Contribute/Form/Task/Invoice.php | 4 ++-- CRM/Core/BAO/Address.php | 6 +++--- CRM/Member/Form/Membership.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index 121bf65ec0..e9ed0e2e0b 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -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; } } diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index 032ecee9a1..df274fd788 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -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++; diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index d4575a2862..b21338e75f 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -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.")); } } -- 2.25.1