I'm running uc_cim on a D6/UC2 site. Most of the time it works beautifully, but now and then, for no apparent reason, some users get a bug that looks like this:

user warning: Duplicate entry '8388607' for key 1
query: INSERT INTO uc_cim (uid, customer_profile_id) VALUES (213124447, 4092207) in /var/www/vhosts/facinghistory.org/httpdocs/sites/all/modules/uc_cim/uc_cim.module on line 2239.

It always complains about that specific number - 8388607 - no matter which user gets the error (and it has been received by many different users). Any ideas? It doesn't prevent the payment from being completed, but I think it's preventing the profile ID from being stored in our DB, thus causing users who get this error to have to re-enter their card details next time. Please help!

CommentFileSizeAuthor
#2 uc_cim-727098.patch1.72 KBkostajh

Comments

phenaproxima’s picture

I tried doing an "analyze table" on the uc_cim table in phpMyAdmin, and I haven't seen this in a couple of days. I suppose it could have been a DB error unique to my site, unless anyone has any ideas...?

kostajh’s picture

Status: Active » Needs review
StatusFileSize
new1.72 KB

user warning: Duplicate entry '8388607' for key 1 query: INSERT INTO uc_cim (uid, customer_profile_id) VALUES (213124447, 4092207)

The uc_cim module defines the uc_cim table this way:

  $schema['uc_cim'] = array(
    'fields' => array(
      'uid' => array('type' => 'int', 'size' => 'medium', 'not null' => TRUE, 'disp-width' => '9'),
      'customer_profile_id' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11')),
    'primary key' => array('uid'),
  );

Problem is, a uid as large as 213124447 isn't going to fit in a medium size integer field. It always gets mangled and set to 8388607 when the uid is too large for the field, hence the duplicate entry errors.

The solution is to define the uid field the same way that the user.module does. The attached patch modifies the schema this for uc_cim and uc_cim_test tables, and provides a hook_update_N() to bring across those changes to sites already running uc_cim. It was created against uc_cim-HEAD.

torgospizza’s picture

Title: "duplicate key" error » Modify uc_cim schema to use unsigned int, not mediumint, for uid

This is also an issue with the payments table using mediumint. My related issue is at #1066368: order_id field in {uc_payment_cim} should be int not mediumint; storing cim_ppid breaks otherwise. I'll make this subject a little more relevant.

m.stenta’s picture

Status: Needs review » Closed (fixed)

Thanks for the patch kostajh!

Committed!