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

Multisite error - DB Error: already exists

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.2.0
    • Fix Version/s: 4.2.1
    • Component/s: None
    • Labels:
      None

      Description

      Database Error Code: Duplicate entry 'Test Group' for key 'UI_title', 1062
      Additional Details:

      Array
      (
      [callback] => Array
      (
      [0] => CRM_Core_Error
      [1] => handle
      )

      [code] => -5
      [message] => DB Error: already exists
      [mode] => 16
      [debug_info] => INSERT INTO civicrm_group (name , title , is_active , group_type ) VALUES ('Test_Group_tmp' , 'Test Group' , 1 , NULL ) [nativecode=1062 ** Duplicate entry 'Northern Susitna Institute' for key 'UI_title']
      [type] => DB_Error
      [user_info] => INSERT INTO civicrm_group (name , title , is_active , group_type ) VALUES ('Test_Group_tmp' , 'Test Group' , 1 , NULL ) [nativecode=1062 ** Duplicate entry 'Northern Susitna Institute' for key 'UI_title']
      [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_group (name , title , is_active , group_type ) VALUES ('Test_Group_tmp' , 'Test Group' , 1 , NULL ) [nativecode=1062 ** Duplicate entry 'Test Group' for key 'UI_title']"]
      )

      When i try to create a contact or make online contribution get above DB Error: already exists. It's trying to create a group which doesn't exist in civicrm_group twice in order to add every contact to a group. Replicated on clients db for wordpress (sql dump at CRM-10749) when trying to add new contact or make online contribution.

      Here is the patch which fixes this problem.

      Index: CRM/Core/BAO/Domain.php
      ===================================================================
      — CRM/Core/BAO/Domain.php (revision 42260)
      +++ CRM/Core/BAO/Domain.php (working copy)
      @@ -222,7 +222,7 @@
      CRM_Core_Config::domainID(), 'name'
      );
      $groupID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group',

      • $title, 'id', 'title'
        + $title, 'id', 'title', true
        );
        if (empty($groupID) && !empty($title)) {

      getFieldvalue function is called twice and first time it checks whether group is present or not, if not then create and second time it again re-checks but we get no result since it comes from the cache, passed fifth parameter force = true so that it every time checks in db rather in cache.

        Attachments

          Activity

            People

            • Assignee:
              kurund Kurund Jalmi
              Reporter:
              pradeep.nayak Pradeep Nayak
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: