Unable to merge Contacts and Cases with Case custom data , raises error - DB Error: already exists (applies to CiviCRM 5.16.0 - CiviCRM 5.18.alpha1)
Unable to merge Contacts and Cases, raises error - DB Error: already exists (applies to CiviCRM 5.16.0 - CiviCRM 5.18.alpha1)
Screenshots below of the configuration.
Steps to reproduce:
- Create Contact A and Contact B
- Create custom fields for the Case Type
- Create a Case for Contact A
- Select the Case Type with the custom fields. Populate the custom fields.
- Create a Case for Contact B
- Select the Case Type with the custom fields. Populate the custom fields.
- Search for Contact A/B
- Merge Contact A/B
- Observe the DB Error: already exists and merge fails to complete
Agileware ref: CIVICRM-1290
CiviCRM error log outputs the following.
Aug 13 13:20:51 [info] $Fatal Error Details = Array ( [callback] => Array ( [0] => CRM_Core_Error [1] => handle ) [code] => -5 [message] => DB Error: already exists [mode] => 16 [debug_info] => INSERT INTO civicrm_value_product_information_2 (entity_id, product_information_sought_10, product_notes_11, product_information_sent_12) SELECT 32679, product_information_sought_10, product_notes_11, product_information_sent_12 FROM civicrm_value_product_information_2 WHERE civicrm_value_product_information_2.entity_id = 32390 [nativecode=1062 ** Duplicate entry '32679' for key 'unique_entity_id'] [type] => DB_Error [user_info] => INSERT INTO civicrm_value_product_information_2 (entity_id, product_information_sought_10, product_notes_11, product_information_sent_12) SELECT 32679, product_information_sought_10, product_notes_11, product_information_sent_12 FROM civicrm_value_product_information_2 WHERE civicrm_value_product_information_2.entity_id = 32390 [nativecode=1062 ** Duplicate entry '32679' for key 'unique_entity_id'] [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_value_product_information_2 (entity_id, product_information_sought_10, product_notes_11, product_information_sent_12) SELECT 32679, product_information_sought_10, product_notes_11, product_information_sent_12 FROM civicrm_value_product_information_2 WHERE civicrm_value_product_information_2.entity_id = 32390 [nativecode=1062 ** Duplicate entry '32679' for key 'unique_entity_id']"] )
Aug 13 13:20:51 [info] $backTrace = #0 /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Core/Error.php(236): CRM_Core_Error::backtrace("backTrace", TRUE) #1 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::handle(Object(DB_Error)) #2 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/packages/DB.php(985): PEAR_Error->__construct("DB Error: already exists", -5, 16, (Array:2), "INSERT INTO civicrm_value_product_information_2 (entity_id, product_informati...") #3 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-5, 16, (Array:2), "INSERT INTO civicrm_value_product_information_2 (entity_id, product_informati...") #4 /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -5, 16, (Array:2), "INSERT INTO civicrm_value_product_information_2 (entity_id, product_informati...", "DB_Error", TRUE) #5 /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/packages/DB/common.php(1907): PEAR->__call("raiseError", (Array:7)) #6 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-5, NULL, NULL, "INSERT INTO civicrm_value_product_information_2 (entity_id, product_informati...", "1062 ** Duplicate entry '32679' for key 'unique_entity_id'") #7 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError() #8 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("INSERT INTO civicrm_value_product_information_2 (entity_id, product_informati...") #9 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/packages/DB/DataObject.php(2415): DB_common->query("INSERT INTO civicrm_value_product_information_2 (entity_id, product_informati...") #10 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/packages/DB/DataObject.php(1607): DB_DataObject->_query("INSERT INTO civicrm_value_product_information_2 (entity_id, product_informati...") #11 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Core/DAO.php(439): DB_DataObject->query("INSERT INTO civicrm_value_product_information_2 (entity_id, product_informati...") #12 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Core/DAO.php(1414): CRM_Core_DAO->query("INSERT INTO civicrm_value_product_information_2 (entity_id, product_informati...", TRUE) #13 /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Case/BAO/Case.php(2105): CRM_Core_DAO::executeQuery("INSERT INTO civicrm_value_product_information_2 (entity_id, product_informati...") #14 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Case/BAO/Case.php(2006): CRM_Case_BAO_Case::mergeCases(39121, 32679, 39158) #15 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Dedupe/Merger.php(539): CRM_Case_BAO_Case::mergeContacts(39121, 39158, (Array:91), (Array:5), (Array:0)) #16 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Dedupe/Merger.php(1547): CRM_Dedupe_Merger::moveContactBelongings(39121, 39158, (Array:5), (Array:0), (Array:0)) #17 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Contact/Form/Merge.php(314): CRM_Dedupe_Merger::moveAllBelongings("39121", "39158", (Array:19)) #18 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Core/Form.php(495): CRM_Contact_Form_Merge->postProcess() #19 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Core/StateMachine.php(160): CRM_Core_Form->mainProcess() #20 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Next.php(61): CRM_Core_StateMachine->perform(Object(CRM_Contact_Form_Merge), "next", "Next") #21 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Contact_Form_Merge), "next") #22 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Contact_Form_Merge), "next") #23 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("next") #24 /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(114): CRM_Core_Controller->run() #25 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Core/Invoke.php(284): CRM_Utils_Wrapper->run("CRM_Contact_Form_Merge", "Merge Contact", (Array:0)) #26 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Core/Invoke.php(85): CRM_Core_Invoke::runItem((Array:13)) #27 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3)) #28 (closed) /var/www/vhosts/somesite.org.au/sites/all/modules/civicrm/drupal/civicrm.module(444): CRM_Core_Invoke::invoke((Array:3)) #29 (closed) /var/www/vhosts/somesite.org.au/includes/menu.inc(527): civicrm_invoke("contact", "merge") #30 (closed) /var/www/vhosts/somesite.org.au/index.php(21): menu_execute_active_handler() #31 {main}