From 814040ada3847281bb73b61375157f5f3ed8d018 Mon Sep 17 00:00:00 2001 From: colemanw Date: Fri, 21 Jul 2023 20:03:47 -0700 Subject: [PATCH] (REF) Replace CRM_Utils_Array in context of is_numeric() --- CRM/Contact/BAO/ProximityQuery.php | 4 ++-- CRM/Contact/Form/Contact.php | 2 +- CRM/Contact/Selector.php | 4 ++-- CRM/Core/BAO/Mapping.php | 8 ++++---- CRM/Event/BAO/Event.php | 2 +- CRM/Member/Form/MembershipRenewal.php | 2 +- CRM/Price/Form/Field.php | 2 +- CRM/Profile/Selector/Listings.php | 2 +- CRM/Report/Form/Mailing/Detail.php | 8 ++++---- api/v3/Generic.php | 2 +- .../CRM/Contact/Form/Search/Custom/Proximity.php | 4 ++-- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CRM/Contact/BAO/ProximityQuery.php b/CRM/Contact/BAO/ProximityQuery.php index be583c0d21..0350d5a83a 100644 --- a/CRM/Contact/BAO/ProximityQuery.php +++ b/CRM/Contact/BAO/ProximityQuery.php @@ -301,8 +301,8 @@ ACOS( } if ( - !is_numeric(CRM_Utils_Array::value('geo_code_1', $proximityAddress)) || - !is_numeric(CRM_Utils_Array::value('geo_code_2', $proximityAddress)) + !is_numeric($proximityAddress['geo_code_1'] ?? '') || + !is_numeric($proximityAddress['geo_code_2'] ?? '') ) { // we are setting the where clause to 0 here, so we wont return anything $qill .= ': ' . ts('We could not geocode the destination address.'); diff --git a/CRM/Contact/Form/Contact.php b/CRM/Contact/Form/Contact.php index 2b98c60f60..a8411864e1 100644 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@ -890,7 +890,7 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { CRM_Contact_BAO_Contact::processImageParams($params); } - if (is_numeric(CRM_Utils_Array::value('current_employer_id', $params)) && !empty($params['current_employer'])) { + if (is_numeric($params['current_employer_id'] ?? '') && !empty($params['current_employer'])) { $params['current_employer'] = $params['current_employer_id']; } diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index e57cbbcb13..8ad89811a2 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -809,7 +809,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $result->contact_id ); } - elseif ((is_numeric(CRM_Utils_Array::value('geo_code_1', $row))) || + elseif ((is_numeric($row['geo_code_1'] ?? '')) || (!empty($row['city']) && !empty($row['state_province'])) ) { $row['action'] = CRM_Core_Action::formLink( @@ -942,7 +942,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $mask = CRM_Core_Action::mask(array_merge([CRM_Core_Permission::VIEW], $basicPermissions)); } - if ((!is_numeric(CRM_Utils_Array::value('geo_code_1', $row))) && + if ((!is_numeric($row['geo_code_1'] ?? '')) && (empty($row['city']) || empty($row['state_province'])) ) { $mask = $mask & 4095; diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index 217767cd8e..583fa8de59 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -483,14 +483,14 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping implements \Civi\Core\Ho $saveMappingFields['name'] = $v['4'] ?? NULL; } - if (is_numeric(CRM_Utils_Array::value('3', $v))) { + if (is_numeric($v['3'] ?? '')) { $locationTypeId = $v['3'] ?? NULL; } - elseif (is_numeric(CRM_Utils_Array::value('5', $v))) { + elseif (is_numeric($v['5'] ?? '')) { $locationTypeId = $v['5'] ?? NULL; } - if (is_numeric(CRM_Utils_Array::value('4', $v))) { + if (is_numeric($v['4'] ?? '')) { if ($saveMappingFields['name'] === 'im') { $saveMappingFields['im_provider_id'] = $v[4]; } @@ -498,7 +498,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping implements \Civi\Core\Ho $saveMappingFields['phone_type_id'] = $v['4'] ?? NULL; } } - elseif (is_numeric(CRM_Utils_Array::value('6', $v))) { + elseif (is_numeric($v['6'] ?? '')) { $saveMappingFields['phone_type_id'] = $v['6'] ?? NULL; } diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 3875bc5e04..13c18b2f4a 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -470,7 +470,7 @@ $event_summary_limit $ids = []; $params = ['entity_id' => $dao->id, 'entity_table' => 'civicrm_event']; $values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE); - if (is_numeric(CRM_Utils_Array::value('geo_code_1', $values['location']['address'][1])) || + if (is_numeric($values['location']['address'][1]['geo_code_1'] ?? '') || ( !empty($values['location']['address'][1]['city']) && !empty($values['location']['address'][1]['state_province_id']) diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 2452991e3d..de109e6b73 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -567,7 +567,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { // chk for renewal for multiple terms CRM-8750 $numRenewTerms = 1; - if (is_numeric(CRM_Utils_Array::value('num_terms', $this->_params))) { + if (is_numeric($this->_params['num_terms'] ?? '')) { $numRenewTerms = $this->_params['num_terms']; } diff --git a/CRM/Price/Form/Field.php b/CRM/Price/Form/Field.php index c9d05a25e3..ad39c0dece 100644 --- a/CRM/Price/Form/Field.php +++ b/CRM/Price/Form/Field.php @@ -427,7 +427,7 @@ class CRM_Price_Form_Field extends CRM_Core_Form { } } - if ((is_numeric(CRM_Utils_Array::value('count', $fields)) && + if ((is_numeric($fields['count'] ?? '') && empty($fields['count']) ) && (($fields['html_type'] ?? NULL) == 'Text') diff --git a/CRM/Profile/Selector/Listings.php b/CRM/Profile/Selector/Listings.php index 8a14a5bf4d..dbec1ab1ac 100644 --- a/CRM/Profile/Selector/Listings.php +++ b/CRM/Profile/Selector/Listings.php @@ -428,7 +428,7 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR $field = $vars[$key]; $fieldArray = explode('-', $field['name']); $fieldType = $fieldArray['2'] ?? NULL; - if (is_numeric(CRM_Utils_Array::value('1', $fieldArray))) { + if (is_numeric($fieldArray['1'] ?? '')) { if (!in_array($fieldType, $multipleFields)) { $locationType = new CRM_Core_DAO_LocationType(); $locationType->id = $fieldArray[1]; diff --git a/CRM/Report/Form/Mailing/Detail.php b/CRM/Report/Form/Mailing/Detail.php index 8426bd9907..52df57c7a7 100644 --- a/CRM/Report/Form/Mailing/Detail.php +++ b/CRM/Report/Form/Mailing/Detail.php @@ -345,7 +345,7 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { } if (array_key_exists('reply_id', $this->_params['fields']) || - is_numeric(CRM_Utils_Array::value('is_replied_value', $this->_params)) + is_numeric($this->_params['is_replied_value'] ?? '') ) { if (($this->_params['is_replied_value'] ?? NULL) == 1) { $joinType = 'INNER'; @@ -363,7 +363,7 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { } if (array_key_exists('unsubscribe_id', $this->_params['fields']) || - is_numeric(CRM_Utils_Array::value('is_unsubscribed_value', $this->_params)) + is_numeric($this->_params['is_unsubscribed_value'] ?? '') ) { if (($this->_params['is_unsubscribed_value'] ?? NULL) == 1 ) { @@ -383,7 +383,7 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { } if (array_key_exists('optout_id', $this->_params['fields']) || - is_numeric(CRM_Utils_Array::value('is_optout_value', $this->_params)) + is_numeric($this->_params['is_optout_value'] ?? '') ) { if (($this->_params['is_optout_value'] ?? NULL) == 1) { $joinType = 'INNER'; @@ -402,7 +402,7 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { } if (array_key_exists('forward_id', $this->_params['fields']) || - is_numeric(CRM_Utils_Array::value('is_forwarded_value', $this->_params)) + is_numeric($this->_params['is_forwarded_value'] ?? '') ) { if (($this->_params['is_forwarded_value'] ?? NULL) == 1) { $joinType = 'INNER'; diff --git a/api/v3/Generic.php b/api/v3/Generic.php index 4310bd585b..690ff54af4 100644 --- a/api/v3/Generic.php +++ b/api/v3/Generic.php @@ -279,7 +279,7 @@ function _civicrm_api3_generic_getfield_spec(&$params, $apiRequest) { function civicrm_api3_generic_getcount($apiRequest) { $apiRequest['params']['options']['is_count'] = TRUE; $result = civicrm_api($apiRequest['entity'], 'get', $apiRequest['params']); - if (is_numeric(CRM_Utils_Array::value('values', $result))) { + if (is_numeric($result['values'] ?? '')) { return (int) $result['values']; } if (!isset($result['count'])) { diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/Proximity.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/Proximity.php index d33c0731a4..5c7bdebcd6 100644 --- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/Proximity.php +++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/Proximity.php @@ -278,8 +278,8 @@ class CRM_Contact_Form_Search_Custom_Proximity extends CRM_Contact_Form_Search_C public function formRule($fields, $files, $self) { $this->addGeocodingData($fields); - if (!is_numeric(CRM_Utils_Array::value('geo_code_1', $fields)) || - !is_numeric(CRM_Utils_Array::value('geo_code_2', $fields)) || + if (!is_numeric($fields['geo_code_1'] ?? '') || + !is_numeric($fields['geo_code_2'] ?? '') || !isset($fields['distance']) ) { $errorMessage = ts('Could not determine co-ordinates for provided data'); -- 2.25.1