From: colemanw Date: Tue, 4 Jul 2023 21:21:32 +0000 (-0400) Subject: REF - Replace CRM_Utils_Array::value with ?? X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=25b2da8d327e5873f64c4e42d2ed8c1070e7986b;p=civicrm-core.git REF - Replace CRM_Utils_Array::value with ?? --- diff --git a/CRM/Campaign/Page/DashBoard.php b/CRM/Campaign/Page/DashBoard.php index 566f1dc5b4..12973f87f7 100644 --- a/CRM/Campaign/Page/DashBoard.php +++ b/CRM/Campaign/Page/DashBoard.php @@ -335,7 +335,7 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { $sid ); - if (CRM_Utils_Array::value('activity_type', $surveysData[$sid]) != 'Petition') { + if (($surveysData[$sid]['activity_type'] ?? NULL) != 'Petition') { $surveysData[$sid]['voterLinks'] = CRM_Campaign_BAO_Survey::buildPermissionLinks($sid, TRUE, ts('more') diff --git a/CRM/Campaign/Page/SurveyType.php b/CRM/Campaign/Page/SurveyType.php index e85650d6c7..d1e972df52 100644 --- a/CRM/Campaign/Page/SurveyType.php +++ b/CRM/Campaign/Page/SurveyType.php @@ -131,7 +131,7 @@ class CRM_Campaign_Page_SurveyType extends CRM_Core_Page_Basic { $optionValues = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight'); foreach ($optionValues as $key => $optionValue) { - if (CRM_Utils_Array::value('component_id', $optionValue) != $campaingCompId) { + if (($optionValue['component_id'] ?? NULL) != $campaingCompId) { unset($optionValues[$key]); } } diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index 90f6030d50..9613965025 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -1404,7 +1404,7 @@ HERESQL; $displayName = $info['display_name'] ?? NULL; - [$result[CRM_Utils_Array::value('contact_id', $info)], $subject, $message, $html] = CRM_Core_BAO_MessageTemplate::sendTemplate( + [$result[$info['contact_id'] ?? NULL], $subject, $message, $html] = CRM_Core_BAO_MessageTemplate::sendTemplate( [ 'groupName' => 'msg_tpl_workflow_case', 'workflow' => 'case_activity', @@ -1435,7 +1435,7 @@ HERESQL; $recordedActivityParams['target_contact_id'][] = $info['contact_id']; } else { - unset($result[CRM_Utils_Array::value('contact_id', $info)]); + unset($result[$info['contact_id'] ?? NULL]); } } diff --git a/CRM/Case/XMLProcessor/Report.php b/CRM/Case/XMLProcessor/Report.php index 2668a61db8..05b29fb534 100644 --- a/CRM/Case/XMLProcessor/Report.php +++ b/CRM/Case/XMLProcessor/Report.php @@ -856,7 +856,7 @@ LIMIT 1 ); } if (!array_key_exists(CRM_Utils_Array::value('display_name', $client), $report->_redactionStringRules)) { - $report->_redactionStringRules[CRM_Utils_Array::value('display_name', $client)] = $report->_redactionStringRules[CRM_Utils_Array::value('sort_name', $client)]; + $report->_redactionStringRules[$client['display_name'] ?? NULL] = $report->_redactionStringRules[$client['sort_name'] ?? NULL]; } $client['sort_name'] = $report->redact(CRM_Utils_Array::value('sort_name', $client), TRUE, $report->_redactionStringRules); if (!empty($client['email']) && diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 6ebc10a0ea..0b0fa9138c 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -6556,7 +6556,7 @@ AND displayRelType.is_active = 1 } $pseudoConstant = $realField['pseudoconstant']; if (empty($pseudoConstant['optionGroupName']) && - CRM_Utils_Array::value('labelColumn', $pseudoConstant) !== 'name') { + ($pseudoConstant['labelColumn'] ?? NULL) !== 'name') { // We are increasing our pseudoconstant handling - but still very cautiously, // hence the check for labelColumn === name return FALSE; @@ -6990,8 +6990,8 @@ AND displayRelType.is_active = 1 */ protected function isPseudoFieldAnFK($fieldSpec) { if (empty($fieldSpec['FKClassName']) - || CRM_Utils_Array::value('keyColumn', $fieldSpec['pseudoconstant']) !== 'id' - || CRM_Utils_Array::value('labelColumn', $fieldSpec['pseudoconstant']) !== 'name') { + || ($fieldSpec['pseudoconstant']['keyColumn'] ?? NULL) !== 'id' + || ($fieldSpec['pseudoconstant']['labelColumn'] ?? NULL) !== 'name') { return FALSE; } return TRUE; diff --git a/CRM/Contact/Form/Task/SMSCommon.php b/CRM/Contact/Form/Task/SMSCommon.php index 95cd3b627a..a86c490221 100644 --- a/CRM/Contact/Form/Task/SMSCommon.php +++ b/CRM/Contact/Form/Task/SMSCommon.php @@ -191,7 +191,7 @@ class CRM_Contact_Form_Task_SMSCommon { unset($form->_contactDetails[$contactId]); continue; } - elseif ($contactDetails['phone_type_id'] != CRM_Utils_Array::value('Mobile', $phoneTypes)) { + elseif ($contactDetails['phone_type_id'] != ($phoneTypes['Mobile'] ?? NULL)) { //if phone is not primary check if non-primary phone is "Mobile" $filter = ['do_not_sms' => 0]; $contactPhones = CRM_Core_BAO_Phone::allPhones($contactId, FALSE, 'Mobile', $filter); diff --git a/CRM/Core/BAO/Navigation.php b/CRM/Core/BAO/Navigation.php index 2910a23b8c..470280d4ac 100644 --- a/CRM/Core/BAO/Navigation.php +++ b/CRM/Core/BAO/Navigation.php @@ -82,7 +82,7 @@ class CRM_Core_BAO_Navigation extends CRM_Core_DAO_Navigation { } if (!isset($params['id']) || - (CRM_Utils_Array::value('parent_id', $params) != CRM_Utils_Array::value('current_parent_id', $params)) + (($params['parent_id'] ?? NULL) != ($params['current_parent_id'] ?? NULL)) ) { /* re/calculate the weight, if the Parent ID changed OR create new menu */ diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index d99b228296..94626883d4 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1677,7 +1677,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { [, $id] = explode('_', $name); $label = $props['label'] ?? CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', 'label', $id); $gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', 'option_group_id', $id); - if (CRM_Utils_Array::value('context', $props) != 'search') { + if (($props['context'] ?? NULL) != 'search') { $props['data-option-edit-path'] = array_key_exists('option_url', $props) ? $props['option_url'] : 'civicrm/admin/options/' . CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $gid); } } @@ -1694,7 +1694,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } } $label = $props['label'] ?? $fieldSpec['html']['label'] ?? $fieldSpec['title']; - if (CRM_Utils_Array::value('context', $props) != 'search') { + if (($props['context'] ?? NULL) != 'search') { $props['data-option-edit-path'] = array_key_exists('option_url', $props) ? $props['option_url'] : CRM_Core_PseudoConstant::getOptionEditUrl($fieldSpec); } } diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 42ba2ab1bb..20baaa48c7 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1339,7 +1339,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $updateStatusMsg = NULL; //send mail when participant status changed, CRM-4326 if ($this->_id && $this->_statusId && - $this->_statusId != CRM_Utils_Array::value('status_id', $params) && !empty($params['is_notify']) + $this->_statusId != ($params['status_id'] ?? NULL) && !empty($params['is_notify']) ) { $updateStatusMsg = CRM_Event_BAO_Participant::updateStatusMessage($this->_id, diff --git a/CRM/Event/Page/EventInfo.php b/CRM/Event/Page/EventInfo.php index c279ea153b..bb0b940b7c 100644 --- a/CRM/Event/Page/EventInfo.php +++ b/CRM/Event/Page/EventInfo.php @@ -114,7 +114,7 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { foreach ($priceSetFields as $fid => $fieldValues) { if (!is_array($fieldValues['options']) || empty($fieldValues['options']) || - (CRM_Utils_Array::value('visibility_id', $fieldValues) != array_search('public', $visibility) && $adminFieldVisible == FALSE) + (($fieldValues['visibility_id'] ?? NULL) != array_search('public', $visibility) && $adminFieldVisible == FALSE) ) { continue; } @@ -132,7 +132,7 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { } foreach ($fieldValues['options'] as $optionId => $optionVal) { - if (CRM_Utils_Array::value('visibility_id', $optionVal) != array_search('public', $visibility) && + if (($optionVal['visibility_id'] ?? NULL) != array_search('public', $visibility) && $adminFieldVisible == FALSE ) { continue; diff --git a/CRM/Financial/BAO/EntityFinancialAccount.php b/CRM/Financial/BAO/EntityFinancialAccount.php index f7ba3dd7cd..80363d1844 100644 --- a/CRM/Financial/BAO/EntityFinancialAccount.php +++ b/CRM/Financial/BAO/EntityFinancialAccount.php @@ -265,7 +265,7 @@ class CRM_Financial_BAO_EntityFinancialAccount extends CRM_Financial_DAO_EntityF public static function validateRelationship($financialTypeAccount) { $financialAccountLinks = CRM_Financial_BAO_FinancialAccount::getfinancialAccountRelations(); $financialAccountType = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $financialTypeAccount->financial_account_id, 'financial_account_type_id'); - if (CRM_Utils_Array::value($financialTypeAccount->account_relationship, $financialAccountLinks) != $financialAccountType) { + if (($financialAccountLinks[$financialTypeAccount->account_relationship] ?? NULL) != $financialAccountType) { $accountRelationships = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship'); throw new CRM_Core_Exception(ts("This financial account cannot have '%1' relationship.", [1 => $accountRelationships[$financialTypeAccount->account_relationship]])); } diff --git a/CRM/Financial/Form/FinancialAccount.php b/CRM/Financial/Form/FinancialAccount.php index c90572a326..37e78f90f6 100644 --- a/CRM/Financial/Form/FinancialAccount.php +++ b/CRM/Financial/Form/FinancialAccount.php @@ -146,7 +146,7 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form { $errorMsg['tax_rate'] = ts('Please enter value for tax rate'); } } - if ((CRM_Utils_Array::value('tax_rate', $values) != NULL)) { + if ((($values['tax_rate'] ?? NULL) != NULL)) { if ($values['tax_rate'] < 0 || $values['tax_rate'] >= 100) { $errorMsg['tax_rate'] = ts('Tax Rate Should be between 0 - 100'); } diff --git a/CRM/Financial/Form/FinancialTypeAccount.php b/CRM/Financial/Form/FinancialTypeAccount.php index 07c739474f..b28b57360e 100644 --- a/CRM/Financial/Form/FinancialTypeAccount.php +++ b/CRM/Financial/Form/FinancialTypeAccount.php @@ -212,7 +212,7 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Core_Form { $errorFlag = FALSE; if ($self->_action == CRM_Core_Action::DELETE) { $relationValues = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship'); - if (CRM_Utils_Array::value('financial_account_id', $values) != 'select') { + if (($values['financial_account_id'] ?? NULL) != 'select') { if ($relationValues[$values['account_relationship']] == 'Premiums Inventory Account is' || $relationValues[$values['account_relationship']] == 'Cost of Sales Account is') { $premiumsProduct = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PremiumsProduct', $values['financial_type_id'], 'product_id', 'financial_type_id'); $product = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Product', $values['financial_type_id'], 'name', 'financial_type_id'); diff --git a/CRM/Logging/Schema.php b/CRM/Logging/Schema.php index f1f5847cc4..8094be15c3 100644 --- a/CRM/Logging/Schema.php +++ b/CRM/Logging/Schema.php @@ -722,7 +722,7 @@ WHERE table_schema IN ('{$this->db}', '{$civiDB}')"; if (!empty($specDiff) && $col !== 'id' && !in_array($col, $diff['ADD'])) { if (empty($colSpecs['EXTRA']) || (!empty($colSpecs['EXTRA']) && $colSpecs['EXTRA'] !== 'auto_increment')) { // ignore 'id' column for any spec changes, to avoid any auto-increment mysql errors - if ($civiTableSpecs[$col]['DATA_TYPE'] != CRM_Utils_Array::value('DATA_TYPE', $logTableSpecs[$col]) + if ($civiTableSpecs[$col]['DATA_TYPE'] != ($logTableSpecs[$col]['DATA_TYPE'] ?? NULL) // We won't alter the log if the length is decreased in case some of the existing data won't fit. || CRM_Utils_Array::value('LENGTH', $civiTableSpecs[$col]) > CRM_Utils_Array::value('LENGTH', $logTableSpecs[$col]) ) { @@ -730,12 +730,12 @@ WHERE table_schema IN ('{$this->db}', '{$civiDB}')"; $diff['MODIFY'][] = $col; } elseif ($civiTableSpecs[$col]['DATA_TYPE'] === 'enum' && - CRM_Utils_Array::value('ENUM_VALUES', $civiTableSpecs[$col]) != CRM_Utils_Array::value('ENUM_VALUES', $logTableSpecs[$col]) + ($civiTableSpecs[$col]['ENUM_VALUES'] ?? NULL) != ($logTableSpecs[$col]['ENUM_VALUES'] ?? NULL) ) { // column is enum and the permitted values have changed $diff['MODIFY'][] = $col; } - elseif ($civiTableSpecs[$col]['IS_NULLABLE'] != CRM_Utils_Array::value('IS_NULLABLE', $logTableSpecs[$col]) && + elseif ($civiTableSpecs[$col]['IS_NULLABLE'] != ($logTableSpecs[$col]['IS_NULLABLE'] ?? NULL) && $logTableSpecs[$col]['IS_NULLABLE'] === 'NO' ) { // if is-null property is different, and log table's column is NOT-NULL, surely consider the column diff --git a/CRM/PCP/Page/PCPInfo.php b/CRM/PCP/Page/PCPInfo.php index 53711f255e..b5b39aadb2 100644 --- a/CRM/PCP/Page/PCPInfo.php +++ b/CRM/PCP/Page/PCPInfo.php @@ -164,7 +164,7 @@ class CRM_PCP_Page_PCPInfo extends CRM_Core_Page { 'pageComponent' => $this->_component, ]; - if (!$pcpBlock->is_tellfriend_enabled || CRM_Utils_Array::value('status_id', $pcpInfo) != $approvedId) { + if (!$pcpBlock->is_tellfriend_enabled || ($pcpInfo['status_id'] ?? NULL) != $approvedId) { unset($link['all'][CRM_Core_Action::DETACH]); } diff --git a/CRM/Pledge/Form/Pledge.php b/CRM/Pledge/Form/Pledge.php index 5572b70c4c..eebec8fca5 100644 --- a/CRM/Pledge/Form/Pledge.php +++ b/CRM/Pledge/Form/Pledge.php @@ -310,7 +310,7 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { $this->assign('eachPaymentAmount', $eachPaymentAmount); } - if (CRM_Utils_Array::value('status_id', $this->_values) != + if (($this->_values['status_id'] ?? NULL) != CRM_Core_PseudoConstant::getKey('CRM_Pledge_BAO_Pledge', 'status_id', 'Cancelled') ) { diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php index 040587ba0c..13e86eef23 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -639,7 +639,7 @@ class CRM_Profile_Form extends CRM_Core_Form { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { $htmlType = $field['html_type']; if ((!isset($this->_defaults[$name]) || $htmlType == 'File') && - (CRM_Utils_Array::value('field_type', $field) != 'Activity') + (($field['field_type'] ?? NULL) != 'Activity') ) { CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 22c92527f3..cbb5d16531 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -3462,7 +3462,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND foreach ($table['filters'] as $fieldName => $field) { if ((CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE || CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_TIME) && - CRM_Utils_Array::value('operatorType', $field) != + ($field['operatorType'] ?? NULL) != CRM_Report_Form::OP_MONTH ) { $from = $this->_params["{$fieldName}_from"] ?? NULL; diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index f7a0dbfaec..65a4dc05a6 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -479,7 +479,7 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { // Stats for soft credits if ($this->_softFrom && - CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) != + ($this->_params['contribution_or_soft_value'] ?? NULL) != 'contributions_only' ) { $totalAmount = $average = []; diff --git a/CRM/Report/Form/Instance.php b/CRM/Report/Form/Instance.php index dfb87568a0..ecd3942715 100644 --- a/CRM/Report/Form/Instance.php +++ b/CRM/Report/Form/Instance.php @@ -256,7 +256,7 @@ class CRM_Report_Form_Instance { // CRM-17310 private reports option. $defaults['add_to_my_reports'] = 0; - if (CRM_Utils_Array::value('owner_id', $defaults) != NULL) { + if (($defaults['owner_id'] ?? NULL) != NULL) { $defaults['add_to_my_reports'] = 1; } diff --git a/CRM/UF/Form/Field.php b/CRM/UF/Form/Field.php index 4bfb3ff7a5..dffad119a0 100644 --- a/CRM/UF/Form/Field.php +++ b/CRM/UF/Form/Field.php @@ -647,7 +647,7 @@ class CRM_UF_Form_Field extends CRM_Core_Form { $params = ['id' => $customField->custom_group_id]; $customGroup = []; CRM_Core_BAO_CustomGroup::retrieve($params, $customGroup); - if (($fieldType != CRM_Utils_Array::value('extends', $customGroup)) || empty($customGroup['extends_entity_column_value'])) { + if (($fieldType != ($customGroup['extends'] ?? NULL)) || empty($customGroup['extends_entity_column_value'])) { return $errors; } diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index fff3068e8b..0159874e7d 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -83,10 +83,10 @@ class CRM_Utils_Date { $date['d'] = sprintf('%02d', $date['d']); $time = ''; - if (CRM_Utils_Array::value('H', $date) != NULL || - CRM_Utils_Array::value('h', $date) != NULL || - CRM_Utils_Array::value('i', $date) != NULL || - CRM_Utils_Array::value('s', $date) != NULL + if (!empty($date['H']) || + !empty($date['h']) || + !empty($date['i']) || + !empty($date['s']) ) { // we have time too.. if (!empty($date['h'])) { diff --git a/CRM/Utils/Pager.php b/CRM/Utils/Pager.php index d0c7a1d557..8f7a2bdf4a 100644 --- a/CRM/Utils/Pager.php +++ b/CRM/Utils/Pager.php @@ -182,7 +182,7 @@ class CRM_Utils_Pager extends Pager_Sliding { // else if a value is set that has higher priority and finally the GET var $currentPage = $defaultPageId; if (!empty($_POST)) { - if (isset($_POST[CRM_Utils_Array::value('buttonTop', $params)]) && isset($_POST[self::PAGE_ID])) { + if (isset($_POST[$params['buttonTop']]) && isset($_POST[self::PAGE_ID])) { $currentPage = max((int ) @$_POST[self::PAGE_ID], 1); } elseif (isset($_POST[$params['buttonBottom']]) && isset($_POST[self::PAGE_ID_BOTTOM])) {