CRM-12556 - Treat string "202" and number 202 the same
authorTim Otten <totten@civicrm.org>
Sat, 11 May 2013 00:17:40 +0000 (20:17 -0400)
committerTim Otten <totten@civicrm.org>
Sat, 20 Jul 2013 17:46:44 +0000 (10:46 -0700)
----------------------------------------
* CRM-12556: Assign api_key for a user via command-line
  http://issues.civicrm.org/jira/browse/CRM-12556

api/v3/utils.php

index c680e00b8e4e208ef25674c7de450a92234201df..8745b09c89633f1ade21817d7ab4540a34a88416 100644 (file)
@@ -1472,10 +1472,10 @@ function _civicrm_api3_validate_integer(&$params, &$fieldName, &$fieldInfo, $ent
   //if fieldname exists in params
   if (CRM_Utils_Array::value($fieldname, $params)) {
     // if value = 'user_contact_id' (or similar), replace value with contact id
-    if (!is_integer($params[$fieldname])) {
+    if (!is_numeric($params[$fieldname])) {
       $realContactId = _civicrm_api3_resolve_contactID($params[$fieldname]);
       if (!is_numeric($realContactId)) {
-        throw new API_Exception("\"$fieldname\" cannot be resolved to a contact ID", 2002, array('error_field' => $fieldname,"type"=>"integer"));
+        throw new API_Exception("\"$fieldname\" \"{$params[$fieldname]}\" cannot be resolved to a contact ID", 2002, array('error_field' => $fieldname,"type"=>"integer"));
       }
       $params[$fieldname] = $realContactId;
     }
@@ -1531,6 +1531,7 @@ function  _civicrm_api3_resolve_contactID($contactIdExpr) {
 
     return $contactID;
   }
+  return NULL;
 }
 
 function _civicrm_api3_validate_html(&$params, &$fieldName, &$fieldInfo) {