0

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: Adding a return statement on 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
});
  • Generally, modifying core code is frowned on. It would be better to include the code leading up to the API call. – DaveD - BackOffice Thinking Jul 3 '17 at 17:06
  • Have you called civicrm_initialize() prior to calling the API? – DaveD - BackOffice Thinking Jul 3 '17 at 17:10
  • The api call is in JS in a blank new civi-native extension. But the same error message is in the API Explorer. – Carlos NLF Jul 3 '17 at 18:00
  • Good, it's helpful to know that it's happening in the API explorer as well. – DaveD - BackOffice Thinking Jul 3 '17 at 18:29
  • 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. – DaveD - BackOffice Thinking Jul 3 '17 at 18:31
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.

  • Jon... it looks like this was a problem before with regard to filtering on contact_id issues.civicrm.org/jira/browse/…). In this case, there are no filters and the error is occuring. – DaveD - BackOffice Thinking Jul 5 '17 at 15:27
  • 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? – Carlos NLF Jul 7 '17 at 13:32
  • It looks like the fix is in this patch: 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. – Jon G - Megaphone Tech Jul 7 '17 at 15:15
  • 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? – Carlos NLF Jul 11 '17 at 14:54
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.

  • Yes, ran a few clean installs and the earliest version that worked is in 4.7.0 – Carlos NLF Jul 7 '17 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.