Enable api_v3_syntaxConformaceTest::testInvalidID_delete (#9068)
[civicrm-core.git] / api / v3 / GroupContact.php
index 1546b692a9c52f6d27f5093445f05b90519832f0..e296e18297ad20c8cf3c66468f35954fbdb0353d 100644 (file)
@@ -146,6 +146,10 @@ function civicrm_api3_group_contact_create($params) {
  * @deprecated
  */
 function civicrm_api3_group_contact_delete($params) {
+  $groupContact = civicrm_api3('GroupContact', 'get', $params);
+  if ($groupContact['count'] == 0) {
+    throw new API_Exception('Cannot Delete GroupContact');
+  }
   $params['status'] = CRM_Utils_Array::value('status', $params, empty($params['skip_undelete']) ? 'Removed' : 'Deleted');
   // "Deleted" isn't a real option so skip the api wrapper to avoid pseudoconstant validation
   return civicrm_api3_group_contact_create($params);