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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • sync civicrm users to Drupal - fails with error
Pages: [1]

Author Topic: sync civicrm users to Drupal - fails with error  (Read 1809 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
sync civicrm users to Drupal - fails with error
January 20, 2010, 03:25:32 pm
Hello,

On a site recently upgraded to 3.0.2 I am trying to sync CiviCRM users to Drupal users.

However, this is resulting in an error because there are two Drupal users that it is trying to match to one contact. The contact has two e-mail addresses - a primary and a billing. There is a Drupal account with an e-mail that matches the primary and one that matches the billing.

Even if I delete the UF_match entry & retry I get a fatal error due to it trying to insert two records with the same contact_id into the civicrm_uf_match table.

The billing_email is not set to primary.





Synchronize Users to Contacts

unrecoverable error
    Sorry. A non-recoverable error has occurred.

    DB Error: already exists

    Return to home page.
Code: [Select]
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_uf_match (domain_id , uf_id , uf_name , contact_id ) VALUES ( 1 ,  12 , 'mail@gmail.com' ,  35 )  [nativecode=1062 ** Duplicate entry '35-1' for key 3]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALUES ( 1 ,  12 , 'mail@gmail.com' ,  35)  [nativecode=1062 ** Duplicate entry '35-1' for key 3]
    [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALUES ( 1 ,  12 , 'mail@gmail.com' ,  35 )  [nativecode=1062 ** Duplicate entry '35-1' for key 3]"]
)
[/code]
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: sync civicrm users to Drupal - fails with error
January 20, 2010, 07:23:50 pm

maybe we should change the sync code and set it to the first email address found sorted by is_primary

wanna check the code and file a patch?

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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: sync civicrm users to Drupal - fails with error
January 20, 2010, 07:42:08 pm
It is being returned Ordered By primary.

line 1550 Contact/BAO/Contact.php

       $query .= " ORDER BY civicrm_email.is_primary DESC";
       
       $dao =& CRM_Core_DAO::executeQuery( $query, $p );

But that doesn't help. What you need here is to make it only search for primary addresses & only return a result if it is the primary (but I don't know the other implications)

Because you have two Drupal users that could match one contact but instead of choosing the most appropriate is chooses to try to do both because when it looks for a contact matching e-mail1 it gets two rows back from the above (email1 & email2) with contactID being the same in both instances.

The comments for the function (CRM_Contact_BAO_Contact::matchContactOnEmail) do suggest that it is supposed to be a match on the primary e-mail:


Code: [Select]
    /**
     * Function to find the get contact details
     *
     * @param string $mail  primary email address of the contact
     * @param string $ctype contact type
     *
     * @return object $dao contact details
     * @static
     */
    static function &matchContactOnEmail( $mail, $ctype = null )
    {
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: sync civicrm users to Drupal - fails with error
March 04, 2010, 07:31:42 pm
Hi,

I've hit this again for another customer. No contacts with more than one e-mail address will sync - are other people not seeing this?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: sync civicrm users to Drupal - fails with error
March 04, 2010, 07:34:32 pm
nb - site is 3.1.3 (recently upgraded)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: sync civicrm users to Drupal - fails with error
March 07, 2010, 02:46:28 am
http://issues.civicrm.org/jira/browse/CRM-5925
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • sync civicrm users to Drupal - fails with error

This forum was archived on 2017-11-26.