-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REF] Cleanup uses of CRM_Utils_Array::value related to numbers #16778
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -373,7 +373,6 @@ public static function buildAdminLinks(&$menu) { | |
$values[$item['adminGroup']] = array(); | ||
$values[$item['adminGroup']]['fields'] = array(); | ||
} | ||
$weight = CRM_Utils_Array::value('weight', $item, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable was unused. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed |
||
$values[$item['adminGroup']]['fields']["{weight}.{$item['title']}"] = $value; | ||
$values[$item['adminGroup']]['component_id'] = $item['component_id']; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,5 @@ | |
* the generated key | ||
*/ | ||
function smarty_function_crmKey($params, &$smarty) { | ||
return CRM_Core_Key::get( | ||
$params['name'], | ||
CRM_Utils_Array::value('addSequence', $params, 0) | ||
); | ||
return CRM_Core_Key::get($params['name'], $params['addSequence'] ?? FALSE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is better because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,7 @@ function _civicrm_api3_dashboard_contact_create_spec(&$params) { | |
function _civicrm_api3_dashboard_contact_check_params(&$params) { | ||
$dashboard_id = CRM_Utils_Array::value('dashboard_id', $params); | ||
if ($dashboard_id) { | ||
$allDashlets = CRM_Core_BAO_Dashboard::getDashlets(TRUE, CRM_Utils_Array::value('check_permissions', $params, 0)); | ||
$allDashlets = CRM_Core_BAO_Dashboard::getDashlets(TRUE, $params['check_permissions'] ?? FALSE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed |
||
if (!isset($allDashlets[$dashboard_id])) { | ||
return civicrm_api3_create_error('Invalid or inaccessible dashboard ID'); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -776,25 +776,21 @@ function _civicrm_api3_apply_filters_to_dao($filterField, $filterValue, &$dao) { | |
function _civicrm_api3_get_options_from_params($params, $queryObject = FALSE, $entity = '', $action = '') { | ||
$lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity); | ||
$is_count = FALSE; | ||
$sort = CRM_Utils_Array::value('sort', $params, 0); | ||
$sort = CRM_Utils_Array::value('option.sort', $params, $sort); | ||
$sort = CRM_Utils_Array::value('option_sort', $params, $sort); | ||
|
||
$offset = CRM_Utils_Array::value('offset', $params, 0); | ||
$offset = CRM_Utils_Array::value('option.offset', $params, $offset); | ||
// dear PHP thought it would be a good idea to transform a.b into a_b in the get/post | ||
$offset = CRM_Utils_Array::value('option_offset', $params, $offset); | ||
$sort = $params['option_sort'] ?? $params['option.sort'] ?? $params['sort'] ?? 0; | ||
$offset = $params['option_offset'] ?? $params['option.offset'] ?? $params['offset'] ?? 0; | ||
|
||
$limit = CRM_Utils_Array::value('rowCount', $params, 25); | ||
$limit = CRM_Utils_Array::value('option.limit', $params, $limit); | ||
$limit = CRM_Utils_Array::value('option_limit', $params, $limit); | ||
|
||
if (is_array(CRM_Utils_Array::value('options', $params))) { | ||
if (isset($params['options']) && is_array($params['options'])) { | ||
// is count is set by generic getcount not user | ||
$is_count = CRM_Utils_Array::value('is_count', $params['options']); | ||
$offset = CRM_Utils_Array::value('offset', $params['options'], $offset); | ||
$limit = CRM_Utils_Array::value('limit', $params['options'], $limit); | ||
$sort = CRM_Utils_Array::value('sort', $params['options'], $sort); | ||
$is_count = $params['options']['is_count'] ?? FALSE; | ||
$offset = $params['options']['offset'] ?? $offset; | ||
$limit = CRM_Utils_Array::value('limit', $params['options'], $limit); | ||
$sort = $params['options']['sort'] ?? $sort; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left |
||
} | ||
|
||
$returnProperties = []; | ||
|
@@ -869,9 +865,7 @@ function _civicrm_api3_get_options_from_params($params, $queryObject = FALSE, $e | |
elseif ($n === 'id') { | ||
$inputParams[$lowercase_entity . '_id'] = $v; | ||
} | ||
elseif (in_array($n, $otherVars)) { | ||
} | ||
else { | ||
elseif (!in_array($n, $otherVars)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was silly. |
||
$inputParams[$n] = $v; | ||
if ($v && !is_array($v) && stristr($v, 'SELECT')) { | ||
throw new API_Exception('invalid string'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before/after should work the same given that it's being passed into
CRM_Utils_Type::escape()