Merge pull request #17656 from civicrm/5.27
[civicrm-core.git] / api / v3 / Contact.php
index f3295353bf804f911f02e3309431ff8659c47bb8..d30d0d0b0995fc8f0142050810e47202323e66c1 100644 (file)
@@ -765,6 +765,10 @@ function civicrm_api3_contact_getquick($params) {
   // If we are doing quicksearch by a field other than name, make sure that field is added to results
   if (!empty($params['field_name'])) {
     $field_name = CRM_Utils_String::munge($params['field_name']);
+    // there is no good reason to request api_key via getquick
+    if ($field_name == 'api_key') {
+      throw new API_Exception('Illegal value "api_key" for parameter "field_name"');
+    }
     // Unique name contact_id = id
     if ($field_name == 'contact_id') {
       $field_name = 'id';
@@ -930,7 +934,7 @@ function civicrm_api3_contact_getquick($params) {
   // Contact's based of relationhip type
   $relType = NULL;
   if (!empty($params['rel'])) {
-    $relation = explode('_', CRM_Utils_Array::value('rel', $params));
+    $relation = explode('_', $params['rel']);
     $relType = CRM_Utils_Type::escape($relation[0], 'Integer');
     $rel = CRM_Utils_Type::escape($relation[2], 'String');
   }
@@ -1036,7 +1040,7 @@ function civicrm_api3_contact_getquick($params) {
   while ($dao->fetch()) {
     $t = ['id' => $dao->id];
     foreach ($as as $k) {
-      $t[$k] = isset($dao->$k) ? $dao->$k : '';
+      $t[$k] = $dao->$k ?? '';
     }
     $t['data'] = $dao->data;
     // Replace keys with values when displaying fields from an option list
@@ -1570,7 +1574,7 @@ function _civicrm_api3_contact_getlist_output($result, $request) {
         $data['description'][] = implode(' ', $address);
       }
       if (!empty($request['image_field'])) {
-        $data['image'] = isset($row[$request['image_field']]) ? $row[$request['image_field']] : '';
+        $data['image'] = $row[$request['image_field']] ?? '';
       }
       else {
         $data['icon_class'] = $row['contact_type'];