From f748c073386b3513a4d227cbd6120ffbc1f786a6 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 17 Mar 2020 16:19:59 +1300 Subject: [PATCH 1/1] [REF] Replace CRM_Utils_Array::value with ?? in variable assignments This is a partial of https://github.com/civicrm/civicrm-core/pull/16768 & consists of the lines I have reviewed from it --- CRM/Contact/BAO/Contact.php | 28 ++++++++++++++-------------- api/api.php | 2 +- api/v3/Activity.php | 8 ++++---- api/v3/Attachment.php | 2 +- api/v3/Contact.php | 14 +++++++------- api/v3/Contribution.php | 6 +++--- api/v3/ContributionPage.php | 2 +- api/v3/CustomValue.php | 4 ++-- api/v3/Domain.php | 4 ++-- api/v3/Generic.php | 10 +++++----- api/v3/GroupContact.php | 4 ++-- api/v3/Job.php | 6 +++--- api/v3/Mailing.php | 18 +++++++++--------- api/v3/MailingEventSubscribe.php | 2 +- api/v3/Membership.php | 4 ++-- api/v3/MembershipStatus.php | 2 +- api/v3/Order.php | 2 +- api/v3/Payment.php | 2 +- api/v3/Setting.php | 2 +- api/v3/utils.php | 8 ++++---- 20 files changed, 65 insertions(+), 65 deletions(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 82eb740b62..54270410c2 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -105,7 +105,7 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { */ public static function add(&$params) { $contact = new CRM_Contact_DAO_Contact(); - $contactID = CRM_Utils_Array::value('contact_id', $params); + $contactID = $params['contact_id'] ?? NULL; if (empty($params)) { return NULL; } @@ -164,7 +164,7 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { $contact->sort_name = substr($contact->sort_name, 0, 128); } - $privacy = CRM_Utils_Array::value('privacy', $params); + $privacy = $params['privacy'] ?? NULL; if ($privacy && is_array($privacy) && !empty($privacy) @@ -1610,7 +1610,7 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); //Sorting fields in alphabetical order(CRM-1507) foreach ($fields as $k => $v) { - $sortArray[$k] = CRM_Utils_Array::value('title', $v); + $sortArray[$k] = $v['title'] ?? NULL; } $fields = array_merge($sortArray, $fields); @@ -1748,7 +1748,7 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); $locationTypeName = 1; } else { - $locationTypeName = CRM_Utils_Array::value($id, $locationTypes); + $locationTypeName = $locationTypes[$id] ?? NULL; if (!$locationTypeName) { continue; } @@ -1814,7 +1814,7 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); $blocks = CRM_Core_BAO_Location::getValues($entityBlock); foreach ($blocks[$block] as $key => $value) { if (!empty($value['is_primary'])) { - $locationType = CRM_Utils_Array::value('location_type_id', $value); + $locationType = $value['location_type_id'] ?? NULL; } } } @@ -2056,8 +2056,8 @@ ORDER BY civicrm_email.is_primary DESC"; $details = self::getHierContactDetails($contactID, $fields); $contactDetails = $details[$contactID]; - $data['contact_type'] = CRM_Utils_Array::value('contact_type', $contactDetails); - $data['contact_sub_type'] = CRM_Utils_Array::value('contact_sub_type', $contactDetails); + $data['contact_type'] = $contactDetails['contact_type'] ?? NULL; + $data['contact_sub_type'] = $contactDetails['contact_sub_type'] ?? NULL; } else { //we should get contact type only if contact @@ -2106,10 +2106,10 @@ ORDER BY civicrm_email.is_primary DESC"; } if ($ctype == 'Organization') { - $data['organization_name'] = CRM_Utils_Array::value('organization_name', $contactDetails); + $data['organization_name'] = $contactDetails['organization_name'] ?? NULL; } elseif ($ctype == 'Household') { - $data['household_name'] = CRM_Utils_Array::value('household_name', $contactDetails); + $data['household_name'] = $contactDetails['household_name'] ?? NULL; } $locationType = []; @@ -2606,7 +2606,7 @@ AND civicrm_openid.is_primary = 1"; CRM_Core_OptionGroup::lookupValues($temp, $names, FALSE); $values['preferred_communication_method'] = $preffComm; - $values['preferred_communication_method_display'] = CRM_Utils_Array::value('preferred_communication_method_display', $temp); + $values['preferred_communication_method_display'] = $temp['preferred_communication_method_display'] ?? NULL; if ($contact->preferred_mail_format) { $preferredMailingFormat = CRM_Core_SelectValues::pmf(); @@ -2623,8 +2623,8 @@ AND civicrm_openid.is_primary = 1"; $birthDate = CRM_Utils_Date::customFormat($contact->birth_date, '%Y%m%d'); if ($birthDate < date('Ymd')) { $age = CRM_Utils_Date::calculateAge($birthDate); - $values['age']['y'] = CRM_Utils_Array::value('years', $age); - $values['age']['m'] = CRM_Utils_Array::value('months', $age); + $values['age']['y'] = $age['years'] ?? NULL; + $values['age']['m'] = $age['months'] ?? NULL; } } @@ -3254,7 +3254,7 @@ AND civicrm_openid.is_primary = 1"; * TRUE if user has all permissions, FALSE if otherwise. */ public static function checkUserMenuPermissions($aclPermissionedTasks, $corePermission, $menuOptions) { - $componentName = CRM_Utils_Array::value('component', $menuOptions); + $componentName = $menuOptions['component'] ?? NULL; // if component action - make sure component is enable. if ($componentName && !in_array($componentName, CRM_Core_Config::singleton()->enableComponents)) { @@ -3264,7 +3264,7 @@ AND civicrm_openid.is_primary = 1"; // make sure user has all required permissions. $hasAllPermissions = FALSE; - $permissions = CRM_Utils_Array::value('permissions', $menuOptions); + $permissions = $menuOptions['permissions'] ?? NULL; if (!is_array($permissions) || empty($permissions)) { $hasAllPermissions = TRUE; } diff --git a/api/api.php b/api/api.php index 7cbc5d180d..85edf1a326 100644 --- a/api/api.php +++ b/api/api.php @@ -267,7 +267,7 @@ function _civicrm_api_replace_variable($value, $parentResult, $separator) { if (array_key_exists($fieldname, $parentResult) && is_array($parentResult[$fieldname])) { $arrayLocation = $parentResult[$fieldname]; foreach ($stringParts as $key => $innerValue) { - $arrayLocation = CRM_Utils_Array::value($innerValue, $arrayLocation); + $arrayLocation = $arrayLocation[$innerValue] ?? NULL; } $value = $arrayLocation; } diff --git a/api/v3/Activity.php b/api/v3/Activity.php index 73f43f05a4..f6734a371c 100644 --- a/api/v3/Activity.php +++ b/api/v3/Activity.php @@ -556,7 +556,7 @@ function _civicrm_api3_activity_get_formatResult($params, $activities, $options) ]); foreach ($activities as &$activity) { if (!empty($activity['case_id'])) { - $case = CRM_Utils_Array::value($activity['case_id'][0], $cases['values']); + $case = $cases['values'][$activity['case_id'][0]] ?? NULL; if ($case) { foreach ($case as $key => $value) { if ($key != 'id') { @@ -705,14 +705,14 @@ function _civicrm_api3_activity_check_params(&$params) { //correctly by doing pseudoconstant validation // needs testing $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate'); - $activityName = CRM_Utils_Array::value('activity_name', $params); + $activityName = $params['activity_name'] ?? NULL; $activityName = ucfirst($activityName); - $activityLabel = CRM_Utils_Array::value('activity_label', $params); + $activityLabel = $params['activity_label'] ?? NULL; if ($activityLabel) { $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'create'); } - $activityTypeId = CRM_Utils_Array::value('activity_type_id', $params); + $activityTypeId = $params['activity_type_id'] ?? NULL; if ($activityName || $activityLabel) { $activityTypeIdInList = array_search(($activityName ? $activityName : $activityLabel), $activityTypes); diff --git a/api/v3/Attachment.php b/api/v3/Attachment.php index b2834091f8..c29d63bd34 100644 --- a/api/v3/Attachment.php +++ b/api/v3/Attachment.php @@ -338,7 +338,7 @@ function __civicrm_api3_attachment_find($params, $id, $file, $entityFile, $isTru * @throws API_Exception validation errors */ function _civicrm_api3_attachment_parse_params($params) { - $id = CRM_Utils_Array::value('id', $params, NULL); + $id = $params['id'] ?? NULL; if ($id && !is_numeric($id)) { throw new API_Exception("Malformed id"); } diff --git a/api/v3/Contact.php b/api/v3/Contact.php index d79910a4c7..d84f039113 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -607,9 +607,9 @@ function _civicrm_api3_greeting_format_params($params) { ]; $greetings = CRM_Core_PseudoConstant::greeting($filter); - $greetingId = CRM_Utils_Array::value("{$key}{$greeting}_id", $params); - $greetingVal = CRM_Utils_Array::value("{$key}{$greeting}", $params); - $customGreeting = CRM_Utils_Array::value("{$key}{$greeting}_custom", $params); + $greetingId = $params["{$key}{$greeting}_id"] ?? NULL; + $greetingVal = $params["{$key}{$greeting}"] ?? NULL; + $customGreeting = $params["{$key}{$greeting}_custom"] ?? NULL; if (!$greetingId && $greetingVal) { $params["{$key}{$greeting}_id"] = CRM_Utils_Array::key($params["{$key}{$greeting}"], $greetings); @@ -1419,11 +1419,11 @@ function _civicrm_api3_contact_proximity_spec(&$params) { * @throws Exception */ function civicrm_api3_contact_proximity($params) { - $latitude = CRM_Utils_Array::value('latitude', $params); - $longitude = CRM_Utils_Array::value('longitude', $params); - $distance = CRM_Utils_Array::value('distance', $params); + $latitude = $params['latitude'] ?? NULL; + $longitude = $params['longitude'] ?? NULL; + $distance = $params['distance'] ?? NULL; - $unit = CRM_Utils_Array::value('unit', $params); + $unit = $params['unit'] ?? NULL; // check and ensure that lat/long and distance are floats if ( diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 66dc25a66f..b9e633a03a 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -356,7 +356,7 @@ function _civicrm_api3_contribution_get_spec(&$params) { $params['financial_type_id']['api.aliases'] = ['contribution_type_id']; $params['payment_instrument_id']['api.aliases'] = ['contribution_payment_instrument', 'payment_instrument']; - $params['contact_id'] = CRM_Utils_Array::value('contribution_contact_id', $params); + $params['contact_id'] = $params['contribution_contact_id'] ?? NULL; $params['contact_id']['api.aliases'] = ['contribution_contact_id']; $params['is_template']['api.default'] = 0; unset($params['contribution_contact_id']); @@ -672,8 +672,8 @@ function _ipn_process_transaction(&$params, $contribution, $input, $ids, $firstC $input['receipt_from_name'] = CRM_Utils_Array::value('receipt_from_name', $params, $domainFromName); $input['receipt_from_email'] = CRM_Utils_Array::value('receipt_from_email', $params, $domainFromEmail); } - $input['card_type_id'] = CRM_Utils_Array::value('card_type_id', $params); - $input['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $params); + $input['card_type_id'] = $params['card_type_id'] ?? NULL; + $input['pan_truncation'] = $params['pan_truncation'] ?? NULL; $transaction = new CRM_Core_Transaction(); return CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects, $transaction, $contribution, CRM_Utils_Array::value('is_post_payment_create', $params)); diff --git a/api/v3/ContributionPage.php b/api/v3/ContributionPage.php index 4202987d17..d744043f71 100644 --- a/api/v3/ContributionPage.php +++ b/api/v3/ContributionPage.php @@ -102,7 +102,7 @@ function civicrm_api3_contribution_page_validate($params) { // authorization from a payment processor like Paypal checkout) the lack of a qfKey will not result in a valid // one being generated so we generate one first. $originalRequest = $_REQUEST; - $qfKey = CRM_Utils_Array::value('qfKey', $_REQUEST); + $qfKey = $_REQUEST['qfKey'] ?? NULL; if (!$qfKey) { $_REQUEST['qfKey'] = CRM_Core_Key::get('CRM_Core_Controller', TRUE); } diff --git a/api/v3/CustomValue.php b/api/v3/CustomValue.php index a524d61571..0711224f00 100644 --- a/api/v3/CustomValue.php +++ b/api/v3/CustomValue.php @@ -347,14 +347,14 @@ function civicrm_api3_custom_value_gettree($params) { $result[$group['name']] = []; $groupToReturn = $toReturn['custom_group'] ? $toReturn['custom_group'] : array_keys($group); foreach ($groupToReturn as $item) { - $result[$group['name']][$item] = CRM_Utils_Array::value($item, $group); + $result[$group['name']][$item] = $group[$item] ?? NULL; } $result[$group['name']]['fields'] = []; foreach ($group['fields'] as $fieldInfo) { $field = ['value' => NULL]; $fieldToReturn = $toReturn['custom_field'] ? $toReturn['custom_field'] : array_keys($fieldInfo); foreach ($fieldToReturn as $item) { - $field[$item] = CRM_Utils_Array::value($item, $fieldInfo); + $field[$item] = $fieldInfo[$item] ?? NULL; } unset($field['customValue']); if (!empty($fieldInfo['customValue'])) { diff --git a/api/v3/Domain.php b/api/v3/Domain.php index de3f425b76..166179f88f 100644 --- a/api/v3/Domain.php +++ b/api/v3/Domain.php @@ -25,7 +25,7 @@ */ function civicrm_api3_domain_get($params) { - $params['version'] = CRM_Utils_Array::value('domain_version', $params); + $params['version'] = $params['domain_version'] ?? NULL; unset($params['version']); $bao = new CRM_Core_BAO_Domain(); @@ -54,7 +54,7 @@ function civicrm_api3_domain_get($params) { ]; if (!empty($values['location']['email'])) { - $domain['domain_email'] = CRM_Utils_Array::value('email', $values['location']['email'][1]); + $domain['domain_email'] = $values['location']['email'][1]['email'] ?? NULL; } if (!empty($values['location']['phone'])) { diff --git a/api/v3/Generic.php b/api/v3/Generic.php index 549ed2a420..fe355becf2 100644 --- a/api/v3/Generic.php +++ b/api/v3/Generic.php @@ -60,8 +60,8 @@ function civicrm_api3_generic_getfields($apiRequest, $unique = TRUE) { } $entity = $apiRequest['entity']; $lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity); - $subentity = CRM_Utils_Array::value('contact_type', $apiRequest['params']); - $action = CRM_Utils_Array::value('action', $apiRequest['params']); + $subentity = $apiRequest['params']['contact_type'] ?? NULL; + $action = $apiRequest['params']['action'] ?? NULL; $sequential = empty($apiRequest['params']['sequential']) ? 0 : 1; $apiRequest['params']['options'] = CRM_Utils_Array::value('options', $apiRequest['params'], []); $optionsToResolve = (array) CRM_Utils_Array::value('get_options', $apiRequest['params']['options'], []); @@ -414,7 +414,7 @@ function civicrm_api3_generic_getoptions($apiRequest) { return civicrm_api3_create_error("The field '{$apiRequest['params']['field']}' doesn't exist."); } // Validate 'context' from params - $context = CRM_Utils_Array::value('context', $apiRequest['params']); + $context = $apiRequest['params']['context'] ?? NULL; CRM_Core_DAO::buildOptionsContext($context); unset($apiRequest['params']['context'], $apiRequest['params']['field'], $apiRequest['params']['condition']); @@ -502,10 +502,10 @@ function _civicrm_api3_generic_get_metadata_options(&$metadata, $apiRequest, $fi } // Allow caller to specify context - $context = CRM_Utils_Array::value('get_options_context', $apiRequest['params']['options']); + $context = $apiRequest['params']['options']['get_options_context'] ?? NULL; // Default to api action if it is a supported context. if (!$context) { - $action = CRM_Utils_Array::value('action', $apiRequest['params']); + $action = $apiRequest['params']['action'] ?? NULL; $contexts = CRM_Core_DAO::buildOptionsContext(); if (isset($contexts[$action])) { $context = $action; diff --git a/api/v3/GroupContact.php b/api/v3/GroupContact.php index 116ec298a6..250438378f 100644 --- a/api/v3/GroupContact.php +++ b/api/v3/GroupContact.php @@ -52,7 +52,7 @@ function civicrm_api3_group_contact_get($params) { } $status = CRM_Utils_Array::value('status', $params, 'Added'); - $groupId = CRM_Utils_Array::value('group_id', $params); + $groupId = $params['group_id'] ?? NULL; $values = CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], $status, NULL, FALSE, TRUE, FALSE, TRUE, $groupId); return civicrm_api3_create_success($values, $params, 'GroupContact'); } @@ -219,7 +219,7 @@ function _civicrm_api3_group_contact_common($params, $op = 'Added') { $method = CRM_Utils_Array::value('method', $params, 'API'); $status = CRM_Utils_Array::value('status', $params, $op); - $tracking = CRM_Utils_Array::value('tracking', $params); + $tracking = $params['tracking'] ?? NULL; if ($op == 'Added' || $op == 'Pending') { $extraReturnValues = [ diff --git a/api/v3/Job.php b/api/v3/Job.php index c3dd38b069..252726d787 100644 --- a/api/v3/Job.php +++ b/api/v3/Job.php @@ -512,7 +512,7 @@ function civicrm_api3_job_process_respondent($params) { * @throws \CiviCRM_API3_Exception */ function civicrm_api3_job_process_batch_merge($params) { - $rule_group_id = CRM_Utils_Array::value('rule_group_id', $params); + $rule_group_id = $params['rule_group_id'] ?? NULL; if (!$rule_group_id) { $rule_group_id = civicrm_api3('RuleGroup', 'getvalue', [ 'contact_type' => 'Individual', @@ -521,8 +521,8 @@ function civicrm_api3_job_process_batch_merge($params) { 'options' => ['limit' => 1], ]); } - $rgid = CRM_Utils_Array::value('rgid', $params); - $gid = CRM_Utils_Array::value('gid', $params); + $rgid = $params['rgid'] ?? NULL; + $gid = $params['gid'] ?? NULL; $mode = CRM_Utils_Array::value('mode', $params, 'safe'); $result = CRM_Dedupe_Merger::batchMerge($rule_group_id, $gid, $mode, 1, 2, CRM_Utils_Array::value('criteria', $params, []), CRM_Utils_Array::value('check_permissions', $params), NULL, $params['search_limit']); diff --git a/api/v3/Mailing.php b/api/v3/Mailing.php index fc7645a049..185b3cd374 100644 --- a/api/v3/Mailing.php +++ b/api/v3/Mailing.php @@ -192,7 +192,7 @@ function civicrm_api3_mailing_clone($params) { $get = civicrm_api3('Mailing', 'getsingle', ['id' => $params['id']]); $newParams = []; - $newParams['debug'] = CRM_Utils_Array::value('debug', $params); + $newParams['debug'] = $params['debug'] ?? NULL; $newParams['groups']['include'] = []; $newParams['groups']['exclude'] = []; $newParams['mailings']['include'] = []; @@ -393,9 +393,9 @@ function civicrm_api3_mailing_event_reply($params) { $queue = $params['event_queue_id']; $hash = $params['hash']; $replyto = $params['replyTo']; - $bodyTxt = CRM_Utils_Array::value('bodyTxt', $params); - $bodyHTML = CRM_Utils_Array::value('bodyHTML', $params); - $fullEmail = CRM_Utils_Array::value('fullEmail', $params); + $bodyTxt = $params['bodyTxt'] ?? NULL; + $bodyHTML = $params['bodyHTML'] ?? NULL; + $fullEmail = $params['fullEmail'] ?? NULL; $mailing = CRM_Mailing_Event_BAO_Reply::reply($job, $queue, $hash, $replyto); @@ -440,8 +440,8 @@ function civicrm_api3_mailing_event_forward($params) { $queue = $params['event_queue_id']; $hash = $params['hash']; $email = $params['email']; - $fromEmail = CRM_Utils_Array::value('fromEmail', $params); - $params = CRM_Utils_Array::value('params', $params); + $fromEmail = $params['fromEmail'] ?? NULL; + $params = $params['params'] ?? NULL; $forward = CRM_Mailing_Event_BAO_Forward::forward($job, $queue, $hash, $email, $fromEmail, $params); @@ -538,7 +538,7 @@ function civicrm_api3_mailing_preview($params) { } $mailing = new CRM_Mailing_BAO_Mailing(); - $mailingID = CRM_Utils_Array::value('id', $params); + $mailingID = $params['id'] ?? NULL; if ($mailingID) { $mailing->id = $mailingID; $mailing->find(TRUE); @@ -555,7 +555,7 @@ function civicrm_api3_mailing_preview($params) { $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id); $returnProperties = $mailing->getReturnProperties(); - $contactID = CRM_Utils_Array::value('contact_id', $params); + $contactID = $params['contact_id'] ?? NULL; if (!$contactID) { // If we still don't have a userID in a session because we are annon then set contactID to be 0 $contactID = empty($session->get('userID')) ? 0 : $session->get('userID'); @@ -564,7 +564,7 @@ function civicrm_api3_mailing_preview($params) { if (!$contactID) { $details = CRM_Utils_Token::getAnonymousTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens()); - $details = CRM_Utils_Array::value(0, $details[0]); + $details = $details[0][0] ?? NULL; } else { $details = CRM_Utils_Token::getTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens()); diff --git a/api/v3/MailingEventSubscribe.php b/api/v3/MailingEventSubscribe.php index b594d772ac..92a8795bdb 100644 --- a/api/v3/MailingEventSubscribe.php +++ b/api/v3/MailingEventSubscribe.php @@ -29,7 +29,7 @@ function civicrm_api3_mailing_event_subscribe_create($params) { $email = $params['email']; $group_id = $params['group_id']; - $contact_id = CRM_Utils_Array::value('contact_id', $params); + $contact_id = $params['contact_id'] ?? NULL; $group = new CRM_Contact_DAO_Group(); $group->is_active = 1; diff --git a/api/v3/Membership.php b/api/v3/Membership.php index 879aeb80ad..8e935373d1 100644 --- a/api/v3/Membership.php +++ b/api/v3/Membership.php @@ -208,7 +208,7 @@ function _civicrm_api3_membership_get_spec(&$params) { function civicrm_api3_membership_get($params) { $activeOnly = $membershipTypeId = $membershipType = NULL; - $contactID = CRM_Utils_Array::value('contact_id', $params); + $contactID = $params['contact_id'] ?? NULL; if (!empty($params['filters']) && is_array($params['filters']) && isset($params['filters']['is_current'])) { $activeOnly = $params['filters']['is_current']; unset($params['filters']['is_current']); @@ -291,7 +291,7 @@ function _civicrm_api3_membership_relationsship_get_customv2behaviour(&$params, // populating relationship type name. $relationshipType = new CRM_Contact_BAO_RelationshipType(); - $relationshipType->id = CRM_Utils_Array::value('relationship_type_id', $membershipType); + $relationshipType->id = $membershipType['relationship_type_id'] ?? NULL; if ($relationshipType->find(TRUE)) { $membershipValues[$membershipId]['relationship_name'] = $relationshipType->name_a_b; } diff --git a/api/v3/MembershipStatus.php b/api/v3/MembershipStatus.php index 97421d09d9..f49c269435 100644 --- a/api/v3/MembershipStatus.php +++ b/api/v3/MembershipStatus.php @@ -72,7 +72,7 @@ function civicrm_api3_membership_status_update($params) { civicrm_api3_verify_mandatory($params, NULL, ['id']); //don't allow duplicate names. - $name = CRM_Utils_Array::value('name', $params); + $name = $params['name'] ?? NULL; if ($name) { $status = new CRM_Member_DAO_MembershipStatus(); $status->name = $params['name']; diff --git a/api/v3/Order.php b/api/v3/Order.php index 464dcd4270..99b270ec29 100644 --- a/api/v3/Order.php +++ b/api/v3/Order.php @@ -74,7 +74,7 @@ function civicrm_api3_order_create($params) { civicrm_api3_verify_one_mandatory($params, NULL, ['line_items', 'total_amount']); $entity = NULL; $entityIds = []; - $contributionStatus = CRM_Utils_Array::value('contribution_status_id', $params); + $contributionStatus = $params['contribution_status_id'] ?? NULL; if ($contributionStatus !== 'Pending' && 'Pending' !== CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contributionStatus)) { CRM_Core_Error::deprecatedFunctionWarning("Creating a Order with a status other than pending is deprecated. Currently empty defaults to 'Completed' so as a transition not passing in 'Pending' is deprecated. You can chain payment creation e.g civicrm_api3('Order', 'create', ['blah' => 'blah', 'contribution_status_id' => 'Pending', 'api.Payment.create => ['total_amount' => 5]]"); } diff --git a/api/v3/Payment.php b/api/v3/Payment.php index cab15b3f3c..32cff589fd 100644 --- a/api/v3/Payment.php +++ b/api/v3/Payment.php @@ -30,7 +30,7 @@ function civicrm_api3_payment_get($params) { $financialTrxn = []; $limit = ''; if (isset($params['options']) && !empty($params['options']['limit'])) { - $limit = CRM_Utils_Array::value('limit', $params['options']); + $limit = $params['options']['limit'] ?? NULL; } $params['options']['limit'] = 0; if (isset($params['trxn_id'])) { diff --git a/api/v3/Setting.php b/api/v3/Setting.php index dc5fc1d6e9..9d8fce5e6c 100644 --- a/api/v3/Setting.php +++ b/api/v3/Setting.php @@ -132,7 +132,7 @@ function _civicrm_api3_setting_getdefaults_spec(&$params) { * @throws \API_Exception */ function civicrm_api3_setting_getoptions($params) { - $domainId = CRM_Utils_Array::value('domain_id', $params); + $domainId = $params['domain_id'] ?? NULL; $specs = \Civi\Core\SettingsMetadata::getMetadata(['name' => $params['field']], $domainId, TRUE); if (empty($specs[$params['field']]) || !is_array(CRM_Utils_Array::value('options', $specs[$params['field']]))) { diff --git a/api/v3/utils.php b/api/v3/utils.php index d7f6598d2f..a6f5665e3a 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -539,10 +539,10 @@ function _civicrm_api3_get_using_query_object($entity, $params, $additional_opti } } $options = array_merge($options, $additional_options); - $sort = CRM_Utils_Array::value('sort', $options, NULL); - $offset = CRM_Utils_Array::value('offset', $options, NULL); - $limit = CRM_Utils_Array::value('limit', $options, NULL); - $smartGroupCache = CRM_Utils_Array::value('smartGroupCache', $params); + $sort = $options['sort'] ?? NULL; + $offset = $options['offset'] ?? NULL; + $limit = $options['limit'] ?? NULL; + $smartGroupCache = $params['smartGroupCache'] ?? NULL; if ($getCount) { $limit = NULL; -- 2.25.1