Merge in 5.47
[civicrm-core.git] / api / api.php
index 795d3c0a341b99190b3338fe4d58770cf1f13e3c..2a857a1db1b8598b568cc1234ad15a044db6d2a9 100644 (file)
@@ -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);
@@ -64,7 +64,7 @@ function civicrm_api4(string $entity, string $action, array $params = [], $index
   $removeIndexField = FALSE;
 
   // 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' && !\Civi\Api4\Utils\SelectUtil::isFieldSelected($indexField, $params['select'])) {
+  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;
   }
@@ -125,7 +125,8 @@ function civicrm_api4(string $entity, string $action, array $params = [], $index
  *
  * @throws CiviCRM_API3_Exception
  *
- * @return array
+ * @return array|int
+ *   Dependant on the $action
  */
 function civicrm_api3(string $entity, string $action, array $params = []) {
   $params['version'] = 3;
@@ -179,7 +180,7 @@ function _civicrm_api3_api_getfields(&$apiRequest) {
  * 'format.is_success' => 1
  * will result in a boolean success /fail being returned if that is what you need.
  *
- * @param $result
+ * @param mixed $result
  *
  * @return bool
  *   true if error, false otherwise