BUG:
First anonymous customer who would try to checkout, will see the error:
user warning: Duplicate entry '1' for key 1 query: INSERT INTO users (name, mail, init, pass, status, uid, created) VALUES ('drupaller', 'drupaller@drupal.org', 'drupaller@drupal.org', '59647d94724bcbf0a3c0dedb83127fc6', 1, 1, 1220950180) in W:\home\ubercart.dan\www\includes\database.mysql.inc on line 172.
The good news are that the order will be registered and available for processing.Customer will also get his account details, but he won't ever log in, because the account hasn't been created!
REASON:
After a couple of hours of code researching I've figured out that the above error is caused by calling user_save function from uc_order.module at line 2293.
user_save function calls db_next_id function from user.module at line 174.
And at that moment db_next_id returns uid = 1, which is already taken for Drupal superuser!
And then no wonder that database query from user.module at line 211 causes an error.
db_next_id makes its queries to sequences database table, which doesn't contain a row users_uid before the first call. That's why it returns uid=1.
SOLUTION:
To fix this bug we need to create a row for users_uid in sequences table during the installation of uc_cart.module, for example. I'm not that clear how to do that correctly, in Drupal-like manner, so I'm asking you guys to help me with that.
Will the code below be a patch for the bug?
//somewhere in the uc_cart_install()...
$max_uid = db_result(db_query("SELECT MAX(uid) AS max_uid FROM {users}"));
if ($max_uid) {
db_query("INSERT INTO {sequences} (name, id) VALUES ('{users}_uid', $max_uid)");
}//somewhere in the uc_cart_uninstall()...
db_query("DELETE FROM {sequences} WHERE name = '{users}_uid'");Thanks a lot for your time!
I'm looking forward for your reply.
Best regards,
captaindan.
| Preview | Attachment | Size |
|---|---|---|
| uc_cart.install.txt | 2.82 KB |

