}
if ($result['count'] == 1) {
- list($result['id']) = array_keys($values);
+ [$result['id']] = array_keys($values);
}
elseif (!empty($values['id']) && is_int($values['id'])) {
$result['id'] = $values['id'];
if ($name === 'MailingRecipients') {
return 'CRM_Mailing_DAO_Recipients';
}
- if ($name === 'AclRole') {
+ if ($name === 'AclRole' || $name === 'ACLRole') {
return 'CRM_ACL_DAO_ACLEntityRole';
}
// FIXME: DAO should be renamed CRM_SMS_DAO_SmsProvider
$returnProperties = NULL;
}
- if (substr($sort, 0, 2) == 'id') {
+ if (substr(($sort ?? ''), 0, 2) == 'id') {
$sort = $lowercase_entity . "_" . $sort;
}
$skipPermissions = !empty($params['check_permissions']) ? 0 : 1;
- list($entities) = CRM_Contact_BAO_Query::apiQuery(
+ [$entities] = CRM_Contact_BAO_Query::apiQuery(
$newParams,
$returnProperties,
NULL,
empty($params['check_permissions']),
TRUE, TRUE, NULL, 'AND', 'NULL', TRUE
);
- list($select, $from, $where, $having) = $query->query();
+ [$select, $from, $where, $having] = $query->query();
$sql = "$select $from $where $having";
}
foreach ($params as $key => $value) {
- list($customFieldID, $customValueID) = CRM_Core_BAO_CustomField::getKeyID($key, TRUE);
+ [$customFieldID, $customValueID] = CRM_Core_BAO_CustomField::getKeyID($key, TRUE);
if ($customFieldID && (!is_null($value))) {
if ($checkCheckBoxField && !empty($fields['custom_' . $customFieldID]) && $fields['custom_' . $customFieldID]['html_type'] == 'CheckBox') {
formatCheckBoxField($value, 'custom_' . $customFieldID, $entity);
* @param string $entity
*/
function _civicrm_api3_format_params_for_create(&$params, $entity) {
+ if (!$entity) {
+ return;
+ }
+ $entity = CRM_Core_DAO_AllCoreTables::convertEntityNameToCamel($entity);
$nonGenericEntities = array_merge(['Contact'], CRM_Contact_BAO_ContactType::basicTypes(TRUE));
$customFieldEntities = array_diff_key(CRM_Core_SelectValues::customGroupExtends(), array_fill_keys($nonGenericEntities, 1));
break;
case CRM_Utils_Type::T_MONEY:
- list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName);
+ [$fieldValue, $op] = _civicrm_api3_field_value_check($params, $fieldName);
foreach ((array) $fieldValue as $fieldvalue) {
if (!CRM_Utils_Rule::money($fieldvalue) && !empty($fieldvalue)) {
break;
case CRM_Utils_Type::T_MONEY:
- list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName);
+ [$fieldValue, $op] = _civicrm_api3_field_value_check($params, $fieldName);
if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
break;
}
* @throws Exception
*/
function _civicrm_api3_validate_date(&$params, &$fieldName, &$fieldInfo) {
- list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName);
- if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
+ [$fieldValue, $op] = _civicrm_api3_field_value_check($params, $fieldName);
+ if (strpos(($op ?? ''), 'NULL') !== FALSE || strpos(($op ?? ''), 'EMPTY') !== FALSE) {
return;
}
* @throws Exception
*/
function _civicrm_api3_validate_unique_key(&$params, &$fieldName) {
- list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName);
+ [$fieldValue, $op] = _civicrm_api3_field_value_check($params, $fieldName);
if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
return;
}
* @return array
*/
function _civicrm_api_get_custom_fields($entity, &$params) {
- $entity = _civicrm_api_get_camel_name($entity);
+ $entity = CRM_Core_DAO_AllCoreTables::convertEntityNameToCamel($entity);
if ($entity == 'Contact') {
// Use sub-type if available, otherwise "NULL" to fetch from all contact types
$entity = $params['contact_type'] ?? NULL;
* @throws API_Exception
*/
function _civicrm_api3_validate_integer(&$params, $fieldName, &$fieldInfo, $entity) {
- list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName);
+ [$fieldValue, $op] = _civicrm_api3_field_value_check($params, $fieldName);
if ($fieldName === 'auto_renew' && $fieldValue === TRUE) {
// https://lab.civicrm.org/dev/rc/-/issues/14
$fieldValue = 1;
}
- if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
+ if (strpos(($op ?? ''), 'NULL') !== FALSE || strpos(($op ?? ''), 'EMPTY') !== FALSE) {
return;
}
}
}
if (
- (!empty($fieldInfo['pseudoconstant']) || !empty($fieldInfo['options']) || $fieldName === 'campaign_id')
- // if it is already numeric AND it is an FK field we don't need to validate because
- // sql will do that for us on insert (this also saves a big lookup)
- && (!is_numeric($fieldValue) || empty($fieldInfo['FKClassName']))
+ !empty($fieldInfo['pseudoconstant']) ||
+ !empty($fieldInfo['options']) ||
+ // Special case for campaign_id which is no longer a pseudoconstant
+ ($fieldName === 'campaign_id' && !CRM_Utils_Rule::positiveInteger($fieldValue))
) {
$additional_lookup_params = [];
if (strtolower($entity) === 'address' && $fieldName == 'state_province_id') {
* @throws API_Exception
*/
function _civicrm_api3_validate_html(&$params, &$fieldName, $fieldInfo) {
- list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName);
+ [$fieldValue, $op] = _civicrm_api3_field_value_check($params, $fieldName);
if (strpos($op, 'NULL') || strpos($op, 'EMPTY')) {
return;
}
*/
function _civicrm_api3_validate_string(&$params, &$fieldName, &$fieldInfo, $entity, $action) {
$isGet = substr($action, 0, 3) === 'get';
- list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName, 'String');
- if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE || CRM_Utils_System::isNull($fieldValue)) {
+ [$fieldValue, $op] = _civicrm_api3_field_value_check($params, $fieldName, 'String');
+ if (strpos(($op ?? ''), 'NULL') !== FALSE || strpos(($op ?? ''), 'EMPTY') !== FALSE || CRM_Utils_System::isNull($fieldValue)) {
return;
}