Merge pull request #1644 from davecivicrm/CRM-13399
[civicrm-core.git] / api / v3 / Generic.php
index 9b3d4e21822ae11672e7f88392a98386dad05165..392fd4cf722872bd583d9e1d093dde147f3260e4 100644 (file)
@@ -113,7 +113,7 @@ function civicrm_api3_generic_getfields($apiRequest) {
   $helper = '_' . $hypApiRequest['function'] . '_spec';
   if (function_exists($helper)) {
     // alter
-    $helper($metadata);
+    $helper($metadata, $apiRequest);
   }
 
   $fieldsToResolve = (array) CRM_Utils_Array::value('get_options', $apiOptions, array());
@@ -139,6 +139,9 @@ function civicrm_api3_generic_getcount($apiRequest) {
   if(is_numeric (CRM_Utils_Array::value('values', $result))) {
     return (int) $result['values'];
   }
+  if(!isset($result['count'])) {
+    throw new API_Exception(ts('Unexpected result from getcount') . print_r($result, TRUE));
+  }
   return $result['count'];
 }