X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fapi.php;h=9ed9747dd0ca0b672fac76462c2f0f9ab911e6b2;hb=982d472ad903315d06eb02cfba6841bf553799bd;hp=be1946db3735796f65dd091d9d3aece9908d98e6;hpb=4c00b9b1a7ccdb06698b7cc0b459856e667ff9e5;p=civicrm-core.git diff --git a/api/api.php b/api/api.php index be1946db37..9ed9747dd0 100644 --- a/api/api.php +++ b/api/api.php @@ -16,7 +16,7 @@ * @param array $params * array to be passed to function * - * @return array|int + * @return array|int|Civi\Api4\Generic\Result */ function civicrm_api(string $entity, string $action, array $params) { return \Civi::service('civi_api_kernel')->runSafe($entity, $action, $params); @@ -63,8 +63,8 @@ function civicrm_api4(string $entity, string $action, array $params = [], $index $indexField = $index && is_string($index) && !CRM_Utils_Rule::integer($index) ? $index : NULL; $removeIndexField = FALSE; - // If index field is not part of the select query, we add it here and remove it below - if ($indexField && !empty($params['select']) && is_array($params['select']) && !\Civi\Api4\Utils\SelectUtil::isFieldSelected($indexField, $params['select'])) { + // If index field is not part of the select query, we add it here and remove it below (except for oddball "Setting" api) + if ($indexField && !empty($params['select']) && is_array($params['select']) && !($entity === 'Setting' && $action === 'get') && !\Civi\Api4\Utils\SelectUtil::isFieldSelected($indexField, $params['select'])) { $params['select'][] = $indexField; $removeIndexField = TRUE; } @@ -73,7 +73,8 @@ function civicrm_api4(string $entity, string $action, array $params = [], $index if ($index && is_array($index)) { $indexCol = reset($index); $indexField = key($index); - if (property_exists($apiCall, 'select')) { + // Index array indicates only 1 or 2 fields need to be selected (except for oddball "Setting" api) + if ($entity !== 'Setting' && property_exists($apiCall, 'select')) { $apiCall->setSelect([$indexCol]); if ($indexField && $indexField != $indexCol) { $apiCall->addSelect($indexField);