Skip to content

Commit

Permalink
Merge pull request #32053 from colemanw/miscDep
Browse files Browse the repository at this point in the history
[REF] CRM/Misc - Refactor out uses of deprecated CRM_Utils_Array::value
  • Loading branch information
eileenmcnaughton authored Feb 11, 2025
2 parents 8a42c09 + 9acf629 commit 0b4bf58
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 21 deletions.
5 changes: 1 addition & 4 deletions CRM/Contact/Selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
$row[$property] = $result->$greeting;
}
elseif (isset($pseudoconstants[$property])) {
$row[$property] = CRM_Utils_Array::value(
$result->{$pseudoconstants[$property]['dbName']},
$pseudoconstants[$property]['values']
);
$row[$property] = $pseudoconstants[$property]['values'][$result->{$pseudoconstants[$property]['dbName']}] ?? NULL;
}
elseif (strpos($property, '-url') !== FALSE) {
$websiteUrl = '';
Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/BAO/WordReplacement.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function edit(&$params, &$id) {
$wordReplacement->id = $id;
$wordReplacement->copyValues($params);
$wordReplacement->save();
if (!isset($params['options']) || CRM_Utils_Array::value('wp-rebuild', $params['options'], TRUE)) {
if (!isset($params['options']) || ($params['options']['wp-rebuild'] ?? TRUE)) {
self::rebuild();
}
return $wordReplacement;
Expand All @@ -66,7 +66,7 @@ public static function create($params) {
$wordReplacement = new CRM_Core_DAO_WordReplacement();
$wordReplacement->copyValues($params);
$wordReplacement->save();
if (!isset($params['options']) || CRM_Utils_Array::value('wp-rebuild', $params['options'], TRUE)) {
if (!isset($params['options']) || ($params['options']['wp-rebuild'] ?? TRUE)) {
self::rebuild();
}
return $wordReplacement;
Expand Down
6 changes: 1 addition & 5 deletions CRM/Core/Invoke.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,7 @@ public static function runItem($item) {

if (isset($item['return_url'])) {
$session = CRM_Core_Session::singleton();
$args = CRM_Utils_Array::value(
'return_url_args',
$item,
'reset=1'
);
$args = $item['return_url_args'] ?? 'reset=1';
$session->pushUserContext(CRM_Utils_System::url($item['return_url'], $args));
}

Expand Down
3 changes: 1 addition & 2 deletions CRM/Core/Page/AJAX/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ public static function getPermissionedLocation() {
}
$elements["onbehalf_{$field}-{$locTypeId}"] = [
'type' => $type,
'value' => isset($location['address'][1]) ? CRM_Utils_Array::value($addField,
$location['address'][1]) : NULL,
'value' => $location['address'][1][$addField] ?? NULL,
];
unset($profileFields["{$field}-{$locTypeId}"]);
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Import/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ private function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params
// Check for custom field values

if (empty($fields['custom'])) {
$fields['custom'] = &CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $values),
$fields['custom'] = &CRM_Core_BAO_CustomField::getFields($values['contact_type'] ?? NULL,
FALSE, FALSE, NULL, NULL, FALSE, FALSE, FALSE
);
}
Expand Down
6 changes: 3 additions & 3 deletions CRM/UF/Form/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function buildQuickForm() {
$defaults['field_type'],
($defaults['field_type'] == "Formatting" ? "" : $defaults['field_name']),
($defaults['field_name'] == "url") ? $defaults['website_type_id'] : $defaults['location_type_id'],
CRM_Utils_Array::value('phone_type_id', $defaults),
$defaults['phone_type_id'] ?? NULL,
];
$this->_gid = $defaults['uf_group_id'];
}
Expand Down Expand Up @@ -548,7 +548,7 @@ public function postProcess() {
CRM_Core_BAO_UFField::resetInSelectorANDSearchable($this->_gid);
}

$this->setMessageIfCountryNotAboveState($fieldName, CRM_Utils_Array::value('location_type_id', $apiFormattedParams), $apiFormattedParams['weight'], $apiFormattedParams['uf_group_id']);
$this->setMessageIfCountryNotAboveState($fieldName, $apiFormattedParams['location_type_id'] ?? NULL, $apiFormattedParams['weight'], $apiFormattedParams['uf_group_id']);

}
$buttonName = $this->controller->getButtonName();
Expand Down Expand Up @@ -804,7 +804,7 @@ public static function formRule($fields, $files, $self) {
$fieldType = $fields['field_name'][0];

//get the group type.
$groupType = CRM_Core_BAO_UFGroup::calculateGroupType($self->_gid, FALSE, CRM_Utils_Array::value('field_id', $fields));
$groupType = CRM_Core_BAO_UFGroup::calculateGroupType($self->_gid, FALSE, $fields['field_id'] ?? NULL);

switch ($fieldType) {
case 'Contact':
Expand Down
5 changes: 1 addition & 4 deletions CRM/Utils/Migrate/ImportJSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,7 @@ public function restore(&$chunk, $daoName, $lookUpMapping = NULL, $dateFields =
foreach ($columns as $k => $column) {
if ($column == 'id') {
$childID = $value[$k];
$masterID = CRM_Utils_Array::value($value[$k],
$this->_lookupCache[$tableName],
NULL
);
$masterID = $this->_lookupCache[$tableName][$value[$k]] ?? NULL;
if ($masterID) {
$object->id = $masterID;
}
Expand Down

0 comments on commit 0b4bf58

Please sign in to comment.