Skip to content
Snippets Groups Projects
Commit 2899f877 authored by Eileen McNaughton's avatar Eileen McNaughton
Browse files

#2743 fix api v3 to not unnecessarily load options

parent 586db1c6
No related branches found
No related tags found
No related merge requests found
...@@ -2078,9 +2078,14 @@ function _civicrm_api3_validate_integer(&$params, $fieldName, &$fieldInfo, $enti ...@@ -2078,9 +2078,14 @@ function _civicrm_api3_validate_integer(&$params, $fieldName, &$fieldInfo, $enti
$fieldValue = NULL; $fieldValue = NULL;
} }
} }
if (!empty($fieldInfo['pseudoconstant']) || !empty($fieldInfo['options']) || $fieldName === 'campaign_id') { 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']))
) {
$additional_lookup_params = []; $additional_lookup_params = [];
if (strtolower($entity) == 'address' && $fieldName == 'state_province_id') { if (strtolower($entity) === 'address' && $fieldName == 'state_province_id') {
$country_id = _civicrm_api3_resolve_country_id($params); $country_id = _civicrm_api3_resolve_country_id($params);
if (!empty($country_id)) { if (!empty($country_id)) {
$additional_lookup_params = ['country_id' => $country_id]; $additional_lookup_params = ['country_id' => $country_id];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment