Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-11215

Batches with custom fields in profile process incorrectly if membership or contribution custom field

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 4.2.3
    • Fix Version/s: Unscheduled
    • Component/s: CiviContribute, CiviMember
    • Labels:
      None

      Description

      Go to the batch profile and add a custom field of type membership or contribution (or any other custom field type EXCEPT for contact custom field).

      Now create a batch-either membership or contribution-and try to process.

      The custom fields will be submitted as contact custom fields in every case--with the entity ID being the contact ID rather than the membership ID, contribution ID, or whatever other entity it should be.

      The result is at worst a DB constraint error (if the contact id submitted doesn't happen to match the FK of the actual entity for that custom field) or at best erroneous data is entered (if the contact ID happens to make with the entity id).

      I tested this quite a bit in 4.2.0 and thought it was working OK. (Though perhaps I just lucked out and never ran into the DB constraint error?) But possibly it is a problem introduced after 4.2.0.

      Backtrace of the error is below. I haven't worked out a patch but the most likely place to address it might be around CRM/Batch/Form/Entry.php(518) where it processes the custom fields as contact data without checking for any other possibilities.


      #1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
      #2 /home/mobikefed/www/www/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
      #3 /home/ourwebsite/www/www/sites/all/modules/civicrm/packages/DB.php(968): PEAR_Error->PEAR_Error("DB Error: constraint violation", -3, 16, (Array:2), "INSERT INTO civicrm_value_contribution_payment_source_for__24 ( membership_d...")
      #4 /home/ourwebsite/www/www/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-3, 16, (Array:2), "INSERT INTO civicrm_value_contribution_payment_source_for__24 ( membership_d...")
      #5 /home/ourwebsite/www/www/sites/all/modules/civicrm/packages/DB/common.php(1903): PEAR->raiseError(NULL, -3, NULL, NULL, "INSERT INTO civicrm_value_contribution_payment_source_for__24 ( membership_d...", "DB_Error", TRUE)
      #6 /home/ourwebsite/www/www/sites/all/modules/civicrm/packages/DB/mysql.php(898): DB_common->raiseError(-3, NULL, NULL, NULL, "1452 ** Cannot add or update a child row: a foreign key constraint fails (`mo...")
      #7 /home/ourwebsite/www/www/sites/all/modules/civicrm/packages/DB/mysql.php(327): DB_mysql->mysqlRaiseError()
      #8 /home/ourwebsite/www/www/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("INSERT INTO civicrm_value_contribution_payment_source_for__24 ( membership_d...")
      #9 /home/ourwebsite/www/www/sites/all/modules/civicrm/packages/DB/DataObject.php(2421): DB_common->query("INSERT INTO civicrm_value_contribution_payment_source_for__24 ( membership_d...")
      #10 /home/ourwebsite/www/www/sites/all/modules/civicrm/packages/DB/DataObject.php(1613): DB_DataObject->query("INSERT INTO civicrm_value_contribution_payment_source_for_24 ( membership_d...")
      #11 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Core/DAO.php(155): DB_DataObject->query("INSERT INTO civicrm_value_contribution_payment_source_for__24 ( membership_d...")
      #12 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Core/DAO.php(922): CRM_Core_DAO->query("INSERT INTO civicrm_value_contribution_payment_source_for__24 ( membership_d...", TRUE)
      #13 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php(238): CRM_Core_DAO::executeQuery("INSERT INTO civicrm_value_contribution_payment_source_for__24 ( membership_d...", (Array:2))
      #14 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php(342): CRM_Core_BAO_CustomValueTable::create((Array:1))
      #15 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Contact/BAO/Contact.php(393): CRM_Core_BAO_CustomValueTable::store((Array:1), "civicrm_contact", "15910")
      #16 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Contact/BAO/Contact.php(1645): CRM_Contact_BAO_Contact::create((Array:18))
      #17 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Batch/Form/Entry.php(719): CRM_Contact_BAO_Contact::createProfileContact((Array:15), (Array:12), "15910")
      #18 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Batch/Form/Entry.php(518): CRM_Batch_Form_Entry->updateContactInfo((Array:15))
      #19 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Batch/Form/Entry.php(325): CRM_Batch_Form_Entry->processMembership((Array:9))
      #20 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Core/Form.php(246): CRM_Batch_Form_Entry->postProcess()
      #21 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(151): CRM_Core_Form->mainProcess()
      #22 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(128): CRM_Core_QuickForm_Action_Upload->realPerform(Object(CRM_Batch_Form_Entry), "upload")
      #23 /home/ourwebsite/www/www/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload->perform(Object(CRM_Batch_Form_Entry), "upload")
      #24 /home/ourwebsite/www/www/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Batch_Form_Entry), "upload")
      #25 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Core/Controller.php(289): HTML_QuickForm_Page->handle("upload")
      #26 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(115): CRM_Core_Controller->run()
      #27 /home/ourwebsite/www/www/sites/all/modules/civicrm/CRM/Core/Invoke.php(193): CRM_Utils_Wrapper->run("CRM_Batch_Form_Entry", NULL, NULL)
      #28 /home/ourwebsite/www/www/sites/all/modules/civicrm/drupal/civicrm.module(382): CRM_Core_Invoke::invoke((Array:3))
      #29 [internal function](): civicrm_invoke("batch", "entry")
      #30 /home/ourwebsite/www/www/includes/menu.inc(350): call_user_func_array("civicrm_invoke", (Array:2))
      #31 /home/ourwebsite/www/www/index.php(17): menu_execute_active_handler()
      #32

      {main}

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              bhugh Brent Hugh
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: