CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Submitting credit card in back-office area fails with SQL error
Pages: [1]

Author Topic: Submitting credit card in back-office area fails with SQL error  (Read 1246 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Submitting credit card in back-office area fails with SQL error
October 04, 2012, 08:21:38 pm
In an environment recently upgraded from version 4.1.5 to 4.2.2, I am seeing an SQL error when submitting a credit card contribution from the back-office area of CiviCRM.  What is odd is that its only happening on some contact records, not all. (Although it is affecting most existing contact records, but not newly created contacts). It is not affecting the creation of non-credit card contributions. ( The payment processor in this environment is Authorize.net, but the transaction never even gets to Authorize.net)

The SQL that is failing:

INSERT INTO civicrm_value_extra_contribution_info  ( deposit_id_24,batch_id_25,temporary_workaround__card_type_49,donation_purpose__general__90,purpose__detail__74,purpose__custom__78,donation_honoree__91,donation_honoree_s__87,acknowledgement_name_93,acknowledgement_name__77,acknowledgee_purpose__82,third_party_payor_26,note_13,entity_id ) VALUES ( 123,123,'Visa','','','',null,'',null,'','',null,'',12663 ) ON DUPLICATE KEY UPDATE deposit_id_24 = 123,batch_id_25 = 123,temporary_workaround__card_type_49 = 'Visa',donation_purpose__general__90 = '',purpose__detail__74 = '',purpose__custom__78 = '',donation_honoree__91 = null,donation_honoree_s__87 = '',acknowledgement_name_93 = null,acknowledgement_name__77 = '',acknowledgee_purpose__82 = '',third_party_payor_26 = null,note_13 = ''


The error message: #1452 - Cannot add or update a child row: a foreign key constraint fails (`dev_crm`.`civicrm_value_extra_contribution_info`, CONSTRAINT `FK_civicrm_value_extra_contribution_info_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `civicrm_contribution` (`id`) ON DE)


The backtrace:

<p>backTrace</p><p><pre>#0 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Core/Error.php(148): CRM_Core_Error::backtrace()
#1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
#2 /home/dev1/public_html/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
#3 /home/dev1/public_html/sites/all/modules/civicrm/packages/DB.php(968): PEAR_Error-&gt;PEAR_Error(&quot;DB Error: constraint violation&quot;, -3, 16, (Array:2), &quot;INSERT INTO civicrm_value_extra_contribution_info  ( deposit_id_24,batch_id_2...&quot;)
#4 /home/dev1/public_html/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error-&gt;DB_Error(-3, 16, (Array:2), &quot;INSERT INTO civicrm_value_extra_contribution_info  ( deposit_id_24,batch_id_2...&quot;)
#5 /home/dev1/public_html/sites/all/modules/civicrm/packages/DB/common.php(1903): PEAR-&gt;raiseError(NULL, -3, NULL, NULL, &quot;INSERT INTO civicrm_value_extra_contribution_info  ( deposit_id_24,batch_id_2...&quot;, &quot;DB_Error&quot;, TRUE)
#6 /home/dev1/public_html/sites/all/modules/civicrm/packages/DB/mysql.php(898): DB_common-&gt;raiseError(-3, NULL, NULL, NULL, &quot;1452 ** Cannot add or update a child row: a foreign key constraint fails (`sa...&quot;)
#7 /home/dev1/public_html/sites/all/modules/civicrm/packages/DB/mysql.php(327): DB_mysql-&gt;mysqlRaiseError()
#8 /home/dev1/public_html/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysql-&gt;simpleQuery(&quot;INSERT INTO civicrm_value_extra_contribution_info  ( deposit_id_24,batch_id_2...&quot;)
#9 /home/dev1/public_html/sites/all/modules/civicrm/packages/DB/DataObject.php(2421): DB_common-&gt;query(&quot;INSERT INTO civicrm_value_extra_contribution_info  ( deposit_id_24,batch_id_2...&quot;)
#10 /home/dev1/public_html/sites/all/modules/civicrm/packages/DB/DataObject.php(1613): DB_DataObject-&gt;_query(&quot;INSERT INTO civicrm_value_extra_contribution_info  ( deposit_id_24,batch_id_2...&quot;)
#11 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Core/DAO.php(155): DB_DataObject-&gt;query(&quot;INSERT INTO civicrm_value_extra_contribution_info  ( deposit_id_24,batch_id_2...&quot;)
#12 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Core/DAO.php(922): CRM_Core_DAO-&gt;query(&quot;INSERT INTO civicrm_value_extra_contribution_info  ( deposit_id_24,batch_id_2...&quot;, TRUE)
#13 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php(236): CRM_Core_DAO::executeQuery(&quot;INSERT INTO civicrm_value_extra_contribution_info  ( deposit_id_24,batch_id_2...&quot;, (Array:14))
#14 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php(340): CRM_Core_BAO_CustomValueTable::create((Array:1))
#15 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Contact/BAO/Contact.php(390): CRM_Core_BAO_CustomValueTable::store((Array:13), &quot;civicrm_contact&quot;, &quot;12663&quot;)
#16 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Contact/BAO/Contact.php(1642): CRM_Contact_BAO_Contact::create((Array:47))
#17 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Contribute/Form/Contribution.php(1271): CRM_Contact_BAO_Contact::createProfileContact((Array:59), (Array:5), &quot;12663&quot;, NULL, NULL, &quot;Individual&quot;)
#18 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Core/Form.php(246): CRM_Contribute_Form_Contribution-&gt;postProcess()
#19 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(151): CRM_Core_Form-&gt;mainProcess()
#20 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(128): CRM_Core_QuickForm_Action_Upload-&gt;realPerform(Object(CRM_Contribute_Form_Contribution), &quot;upload&quot;)
#21 /home/dev1/public_html/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload-&gt;perform(Object(CRM_Contribute_Form_Contribution), &quot;upload&quot;)
#22 /home/dev1/public_html/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller-&gt;handle(Object(CRM_Contribute_Form_Contribution), &quot;upload&quot;)
#23 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Core/Controller.php(289): HTML_QuickForm_Page-&gt;handle(&quot;upload&quot;)
#24 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Contribute/Page/Tab.php(296): CRM_Core_Controller-&gt;run()
#25 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Contribute/Page/Tab.php(353): CRM_Contribute_Page_Tab-&gt;edit()
#26 /home/dev1/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(228): CRM_Contribute_Page_Tab-&gt;run((Array:4), NULL)
#27 /home/dev1/public_html/sites/all/modules/civicrm/drupal/civicrm.module(382): CRM_Core_Invoke::invoke((Array:4))
#28 [internal function](): civicrm_invoke(&quot;contact&quot;, &quot;view&quot;, &quot;contribution&quot;)
#29 /home/dev1/public_html/includes/menu.inc(348): call_user_func_array(&quot;civicrm_invoke&quot;, (Array:3))
#30 /home/dev1/public_html/index.php(18): menu_execute_active_handler()
« Last Edit: October 04, 2012, 08:54:21 pm by Sarah Gladstone »
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Submitting credit card in back-office area fails with SQL error
October 05, 2012, 07:46:45 am
I have been stepping through the code, and am confused by one thing so far.   The SQL that is trying to insert the data into the custom field set table ( The custom field set is called "Extra Contribution Info" and "used for" is set to "Contribution")  is trying to put the contact id (12663) into the "entity_id" field, instead of the contribution id which is expected.
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Submitting credit card in back-office area fails with SQL error
October 05, 2012, 07:52:29 am

this might be a related issue:

http://forum.civicrm.org/index.php/topic,26300.msg111378.html#msg111378

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Submitting credit card in back-office area fails with SQL error

This forum was archived on 2017-11-26.