Answers.Body: <p>I remember this bug from a long time ago.  I'm pretty positive it's been fixed.</p>
  
  <p>I would try upgrading a copy of your site to the latest 4.6 to see if the problem still exists.  If it doesn't, then upgrading is your solution.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T15:27:12.320Z
Answers.Text: Jon... it looks like this was a problem before with regard to filtering on contact_id https://issues.civicrm.org/jira/browse/CRM-16393?jql=project%20%3D%20CRM).  In this case, there are no filters and the error is occuring.
Answers.UserDisplayName: DaveD
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-07T13:32:30.720Z
Answers.Text: Yep, tried 4.6.4, 4.6.5, 4.6.9 and same issue. 4.7.0 worked fine. My only issue is that if I want to make my extension public, it will only work for 4.7.0 users. What about LTS users?
Answers.UserDisplayName: Carlos NLF
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-07T15:15:13.183Z
Answers.Text: It looks like the fix is in this patch: https://github.com/civicrm/civicrm-core/pull/5727.  You can test to see if that's true.  If so, I think you should release this for 4.7 only, but in the README mention that 4.6 users can use it if they apply the patch.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-11T14:54:41.837Z
Answers.Text: The 4.6.4 core files reflect the code in that patch.. so I'm guessing no one had this api contribution get issue for all of 4.6 until 4.7?
Answers.UserDisplayName: Carlos NLF
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T15:13:33.063Z
Answers.LastActivityDate: 2017-07-05T15:13:33.063Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>This is definitely a bug in CiviCRM.  I was able to duplicate it using the API Explorer in the 4.6.29 sandbox.  </p>
  
  <p>I note that the 4.7.x version sandbox did not take this error. You should consider updating your version to that.</p>
  
  <p>I did a quick search in CiviCRM's JIRA but could not see such an issue reported.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-07T13:32:50.043Z
Answers.Text: Yes, ran a few clean installs and the earliest version that worked is in 4.7.0
Answers.UserDisplayName: Carlos NLF
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T15:22:34.900Z
Answers.LastActivityDate: 2017-07-05T15:22:34.900Z
Answers.UserDisplayName: DaveD
Body: <p>CiviCRM 4.6.4/Wordpress.</p>
  
  <p>During API call for Contribution get and parameter id = xxxx, api returns <code>A fatal error was triggered: CiviCRM is not of the type Int</code>.</p>
  
  <p>Adding a return statement in <code>wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Query.php</code> solves the issue but unsure if this will affect other Contribution tasks in production..</p>
  
  <p>Also tried a clean install of 4.6.4 on Wordpress and same issue.</p>
  
  <p>See Line 266:
  <a href="https://i.sstatic.net/mJbHQ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/mJbHQ.png" alt="Adding a return statement on Line 266"></a></p>
  
  <pre><code>{
  "trace": "#0 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Utils/Type.php(269): CRM_Core_Error::fatal('CiviCRM is not ...')\n#1 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(5238): CRM_Utils_Type::escape('CiviCRM', 'Int')\n#2 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Query.php(373): CRM_Contact_BAO_Query::buildClause('civicrm_contrib...', '=', 'CiviCRM', 'Int')\n#3 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Query.php(251): CRM_Contribute_BAO_Query::whereClauseSingle(Array, Object(CRM_Contact_BAO_Query))\n#4 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Core/Component.php(298): CRM_Contribute_BAO_Query::where(Object(CRM_Contact_BAO_Query))\n#5 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(1894): CRM_Core_Component::alterQuery(Object(CRM_Contact_BAO_Query), 'where')\n#6 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(499): CRM_Contact_BAO_Query-&gt;whereClause()\n#7 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(461): CRM_Contact_BAO_Query-&gt;initialize()\n#8 /vagrant/donate/wp-content/plugins/civicrm/civicrm/api/v3/utils.php(595): CRM_Contact_BAO_Query-&gt;__construct(Array, Array, NULL, false, false, 2, false)\n#9 /vagrant/donate/wp-content/plugins/civicrm/civicrm/api/v3/Contribution.php(217): _civicrm_api3_get_query_object(Array, 2, 'Contribution')\n#10 /vagrant/donate/wp-content/plugins/civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_contribution_get(Array)\n#11 /vagrant/donate/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(96): Civi\\API\\Provider\\MagicFunctionProvider-&gt;invoke(Array)\n#12 /vagrant/donate/wp-content/plugins/civicrm/civicrm/api/api.php(23): Civi\\API\\Kernel-&gt;run('Contribution', 'get', Array, NULL)\n#13 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Utils/REST.php(404): civicrm_api('Contribution', 'get', Array)\n#14 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Utils/REST.php(640): CRM_Utils_REST::process(Array, Array)\n#15 [internal function]: CRM_Utils_REST::ajax()\n#16 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(278): call_user_func(Array)\n#17 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(86): CRM_Core_Invoke::runItem(Array)\n#18 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(54): CRM_Core_Invoke::_invoke(Array)\n#19 /vagrant/donate/wp-content/plugins/civicrm/civicrm.php(1188): CRM_Core_Invoke::invoke(Array)\n#20 [internal function]: CiviCRM_For_WordPress-&gt;invoke('')\n#21 /vagrant/donate/wp-includes/class-wp-hook.php(298): call_user_func_array(Array, Array)\n#22 /vagrant/donate/wp-includes/class-wp-hook.php(323): WP_Hook-&gt;apply_filters('', Array)\n#23 /vagrant/donate/wp-includes/plugin.php(453): WP_Hook-&gt;do_action(Array)\n#24 /vagrant/donate/wp-admin/admin.php(222): do_action('toplevel_page_C...')\n#25 {main}",
  "is_error": 1,
  "error_message": "A fatal error was triggered: CiviCRM is not of the type Int"
  }
  </code></pre>
  
  <p>The code</p>
  
  <pre><code>CRM.api3('Contribution', 'get', {
    "debug": 1,
    "sequential": 1
  }).done(function(result) {
    // do something
  });
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-03T17:06:54.070Z
Comments.Text: Generally, modifying core code is frowned on.  It would be better to include the code leading up to the API call.
Comments.UserDisplayName: DaveD
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-03T17:10:25.200Z
Comments.Text: Have you called civicrm_initialize() prior to calling the API?
Comments.UserDisplayName: DaveD
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-03T18:00:39.833Z
Comments.Text: The api call is in JS in a blank new civi-native extension. But the same error message is in the API Explorer.
Comments.UserDisplayName: Carlos NLF
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-03T18:29:34.963Z
Comments.Text: Good, it's helpful to know that it's happening in the API explorer as well.
Comments.UserDisplayName: DaveD
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-03T18:31:17.067Z
Comments.Text: Again, it would be helpful to see the code.  Also, is there anything in the CiviCRM log?  A stack trace would be great if one is available.
Comments.UserDisplayName: DaveD
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T14:04:06.400Z
Comments.Text: updated the post with the debug
Comments.UserDisplayName: Carlos NLF
Tags: <issues>
Title: Can't find a patch for "CiviCRM is not of type Int"
ThreadText: # Can't find a patch for "CiviCRM is not of type Int"
  
  (Asked by: username_0 on 2017-07-03)
  
  CiviCRM 4.6.4/Wordpress.
  During API call for Contribution get and parameter id = xxxx, api returns A fatal error was triggered: CiviCRM is not of the type Int.
  Adding a return statement in wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Query.php solves the issue but unsure if this will affect other Contribution tasks in production..
  Also tried a clean install of 4.6.4 on Wordpress and same issue.
  See Line 266:
  
  {
  "trace": "#0 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Utils/Type.php(269): CRM_Core_Error::fatal('CiviCRM is not ...')\n#1 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(5238): CRM_Utils_Type::escape('CiviCRM', 'Int')\n#2 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Query.php(373): CRM_Contact_BAO_Query::buildClause('civicrm_contrib...', '=', 'CiviCRM', 'Int')\n#3 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Query.php(251): CRM_Contribute_BAO_Query::whereClauseSingle(Array, Object(CRM_Contact_BAO_Query))\n#4 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Core/Component.php(298): CRM_Contribute_BAO_Query::where(Object(CRM_Contact_BAO_Query))\n#5 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(1894): CRM_Core_Component::alterQuery(Object(CRM_Contact_BAO_Query), 'where')\n#6 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(499): CRM_Contact_BAO_Query->whereClause()\n#7 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(461): CRM_Contact_BAO_Query->initialize()\n#8 /vagrant/donate/wp-content/plugins/civicrm/civicrm/api/v3/utils.php(595): CRM_Contact_BAO_Query->__construct(Array, Array, NULL, false, false, 2, false)\n#9 /vagrant/donate/wp-content/plugins/civicrm/civicrm/api/v3/Contribution.php(217): _civicrm_api3_get_query_object(Array, 2, 'Contribution')\n#10 /vagrant/donate/wp-content/plugins/civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_contribution_get(Array)\n#11 /vagrant/donate/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(96): Civi\\API\\Provider\\MagicFunctionProvider->invoke(Array)\n#12 /vagrant/donate/wp-content/plugins/civicrm/civicrm/api/api.php(23): Civi\\API\\Kernel->run('Contribution', 'get', Array, NULL)\n#13 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Utils/REST.php(404): civicrm_api('Contribution', 'get', Array)\n#14 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Utils/REST.php(640): CRM_Utils_REST::process(Array, Array)\n#15 [internal function]: CRM_Utils_REST::ajax()\n#16 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(278): call_user_func(Array)\n#17 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(86): CRM_Core_Invoke::runItem(Array)\n#18 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(54): CRM_Core_Invoke::_invoke(Array)\n#19 /vagrant/donate/wp-content/plugins/civicrm/civicrm.php(1188): CRM_Core_Invoke::invoke(Array)\n#20 [internal function]: CiviCRM_For_WordPress->invoke('')\n#21 /vagrant/donate/wp-includes/class-wp-hook.php(298): call_user_func_array(Array, Array)\n#22 /vagrant/donate/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters('', Array)\n#23 /vagrant/donate/wp-includes/plugin.php(453): WP_Hook->do_action(Array)\n#24 /vagrant/donate/wp-admin/admin.php(222): do_action('toplevel_page_C...')\n#25 {main}",
  "is_error": 1,
  "error_message": "A fatal error was triggered: CiviCRM is not of the type Int"
  }
  
  The code
  CRM.api3('Contribution', 'get', {
    "debug": 1,
    "sequential": 1
  }).done(function(result) {
    // do something
  });
  
  **Tags:** issues
  
  > **Comments:**
  > **username_1**: Generally, modifying core code is frowned on.  It would be better to include the code leading up to the API call.  
  > **username_1**: Have you called civicrm_initialize() prior to calling the API?  
  > **username_0**: The api call is in JS in a blank new civi-native extension. But the same error message is in the API Explorer.  
  > **username_1**: Good, it's helpful to know that it's happening in the API explorer as well.  
  > **username_1**: Again, it would be helpful to see the code.  Also, is there anything in the CiviCRM log?  A stack trace would be great if one is available.  
  > **username_0**: updated the post with the debug  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2017-07-05. Score: 1
  
  I remember this bug from a long time ago. I'm pretty positive it's been fixed.
  
  I would try upgrading a copy of your site to the latest 4.6 to see if the problem still exists. If it doesn't, then upgrading is your solution.
  
  > **Comments:**
  > **username_1**: Jon... it looks like this was a problem before with regard to filtering on contact_id https://issues.civicrm.org/jira/browse/CRM-16393?jql=project%20%3D%20CRM).  In this case, there are no filters and the error is occuring.  
  > **username_0**: Yep, tried 4.6.4, 4.6.5, 4.6.9 and same issue. 4.7.0 worked fine. My only issue is that if I want to make my extension public, it will only work for 4.7.0 users. What about LTS users?  
  > **username_2**: It looks like the fix is in this patch: https://github.com/civicrm/civicrm-core/pull/5727.  You can test to see if that's true.  If so, I think you should release this for 4.7 only, but in the README mention that 4.6 users can use it if they apply the patch.  
  > **username_0**: The 4.6.4 core files reflect the code in that patch.. so I'm guessing no one had this api contribution get issue for all of 4.6 until 4.7?  
  
  ---
  
  ### Answer by username_1 on 2017-07-05. Score: 0
  
  This is definitely a bug in CiviCRM. I was able to duplicate it using the API Explorer in the 4.6.29 sandbox.
  
  I note that the 4.7.x version sandbox did not take this error. You should consider updating your version to that.
  
  I did a quick search in CiviCRM's JIRA but could not see such an issue reported.
  
  > **Comments:**
  > **username_0**: Yes, ran a few clean installs and the earliest version that worked is in 4.7.0  
  
  ---
  
  