From eef1dd7c42aebe2c0fdf02064986133f85bfdd42 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Sat, 22 Apr 2023 19:24:48 +0100 Subject: [PATCH] Code cleanup --- CRM/Contribute/Form/Contribution/Main.php | 3 +-- CRM/Event/BAO/Participant.php | 3 +-- tests/phpunit/CRM/Core/BAO/CustomGroupTest.php | 10 ++++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 9819e8276c..28d3b62023 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -123,7 +123,6 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu if (!empty($contactID)) { $fields = []; - $removeCustomFieldTypes = ['Contribution', 'Membership']; $contribFields = CRM_Contribute_BAO_Contribution::getContributionFields(); // remove component related fields @@ -131,7 +130,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu //don't set custom data Used for Contribution (CRM-1344) if (substr($name, 0, 7) == 'custom_') { $id = substr($name, 7); - if (!CRM_Core_BAO_CustomGroup::checkCustomField($id, $removeCustomFieldTypes)) { + if (!CRM_Core_BAO_CustomGroup::checkCustomField($id, ['Contribution', 'Membership'])) { continue; } // ignore component fields diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index 9d63b3b5cd..6046f9e663 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -1803,11 +1803,10 @@ WHERE civicrm_participant.contact_id = {$contactID} AND } $fields = []; if (!empty($form->_fields)) { - $removeCustomFieldTypes = ['Participant']; foreach ($form->_fields as $name => $fieldInfo) { if ((substr($name, 0, 7) == 'custom_' && !$form->_allowConfirmation - && !CRM_Core_BAO_CustomGroup::checkCustomField(substr($name, 7), $removeCustomFieldTypes)) + && !CRM_Core_BAO_CustomGroup::checkCustomField(substr($name, 7), ['Participant'])) || substr($name, 0, 12) == 'participant_') { continue; } diff --git a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php index abb2a17da1..473edd46df 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php @@ -400,12 +400,14 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase { $this->assertEquals($customFieldLabel, $dbCustomFieldLabel); //check the custom field type. - $params = ['Individual']; - $usedFor = CRM_Core_BAO_CustomGroup::checkCustomField($customFieldId, $params); + $usedFor = CRM_Core_BAO_CustomGroup::checkCustomField( + $customFieldId, ['Individual'] + ); $this->assertEquals(FALSE, $usedFor); - $params = ['Contribution', 'Membership', 'Participant']; - $usedFor = CRM_Core_BAO_CustomGroup::checkCustomField($customFieldId, $params); + $usedFor = CRM_Core_BAO_CustomGroup::checkCustomField( + $customFieldId, ['Contribution', 'Membership', 'Participant'] + ); $this->assertEquals(TRUE, $usedFor); $this->customFieldDelete($customField['id']); -- 2.25.1