In Drupal 6.9 With Ubercart 2.0 Beta3 when you have configured anonymous checkout plus logging the user in automatically you get a Duplicate entry error like below at cart/checkout/complete

user warning: Duplicate entry '' for key 2 query: INSERT INTO users (created) VALUES (1232815823) in /usr/local/www/data/test4/modules/user/user.module on line 327.

I have a strong suspicion this was caused by changes in the user.module between 6.8 and 6.9
#169937: user_save regenerates the session even when current user != edited user.

I could be way off though...

CommentFileSizeAuthor
#14 363847-1.patch437 bytesmickyb

Comments

rszrama’s picture

Status: Active » Postponed (maintainer needs more info)

Hey Tim, I'm not sure on this one... I just enabled the auto-login for new users on the Livetest and completed an anonymous checkout. It logged me in without warning, and there are no similar errors in the watchdog. I'm wondering what other modules you might have enabled that would affect user registration and creation.

The query you're showing here is for inserting an empty user account into the users table, something that Ubercart doesn't do (at least directly). When anonymous checkout happens, Ubercart builds a user object and runs user_save() on that... so at the very least I'd expect there to be an e-mail in that query.

thill_’s picture

Status: Postponed (maintainer needs more info) » Fixed

I can't repeat on any other install, will mark fixed to get it off the list.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

vood002’s picture

I'm receiving this error. Ubercart RC6 and Drupal 6.14.

Duplicate entry '' for key 2 query: INSERT INTO sslab_users (created) VALUES (1253542774) in /home/sporbcom/public_html/modules/user/user.module on line 327.

I'm getting it on every anonymous checkout. Is there any other information I can provide?

vood002’s picture

This problem was being caused, for me, by a conditional action that set the order to "completed" as soon as payment was received. Apparently this caused some things to go out of order and awry.

Anonymous’s picture

Status: Closed (fixed) » Active

I have this problem as well. Any anonymous checkout results in an error message like the following:

user warning: Duplicate entry '' for key 2 query: INSERT INTO users (created) VALUES (1266467414) in /var/www/vhosts/xxx.com.au/httpdocs/modules/user/user.module on line 327.

I tried #5 and this does not fix it. Even if removing that conditional action did work, it would not be a good solution.

Any ideas?

pcorbett’s picture

Same issue but with newer version of ubercart and Drupal 6.15. Any anonymous checkout results in a similar error message. Interestingly, everything seems to go through. I'm using this for role/membership creation and the user is created with the order posting to PayPal and the user receiving a password email -- login works and order is recorded.

(URL obfuscated for privacy purposes)

Referrer: https://xxx.com/cart/checkout/review
Message Duplicate entry '' for key 2 query: INSERT INTO users (created) VALUES (1266505207) in /var/www/xxx.com/modules/user/user.module on line 327.

pcorbett’s picture

Version: 6.x-2.0-beta3 » 6.x-2.2

Update: I debugged uc_roles_grant() and $account is not set correctly upon order submit:

stdClass Object ( [uid] => 0 [name] => [pass] => [mail] => [mode] => 0 [sort] => 0 [threshold] => 0 [theme] => [signature] => [signature_format] => 0 [created] => 0 [access] => 0 [login] => 0 [status] => 0 [timezone] => [language] => [picture] => [init] => [data] => [timezone_name] => [roles] => Array ( [1] => anonymous user ) )
gooddesignusa’s picture

keeping an eye on this one

Anonymous’s picture

gooddesignusa’s picture

seems like a show stopper. hope this gets fixed soon.

valante’s picture

Same with Drupal 6.17, Ubercart 6.x-2.3 . This one's killing me.

YK85’s picture

subscribing

mickyb’s picture

StatusFileSize
new437 bytes

Ok I've found this particular bug and I was able to fix it. The issue here is that the conditional actions that assign the roles to users try to run against the 'anonymous' user account first, then they run against the newly created user. This was causing the errors, since the 'anonymous' user doesn't have any data in it so to speak. So the fix here was simple:

function uc_roles_action_order_renew($order, $settings) {
  // Load the order's user and exit if not available.
  if (!($account = user_load($order->uid)) || $account->uid == 0) {
    return;
  }

 // ... rest of function ...

I've attached a patch that will hopefully be useful to everyone here (to be applied to: ubercart/uc_roles/uc_roles.ca.inc). The issue can probably be solved much deeper in the code, but for my purposes this will suffice.

Thanks to "pcorbett" (comment #8) for the head start :)

Whoever tests this first can add [SOLVED] to the issue title once they've verified that it's working for them too.

--Michael

longwave’s picture

Status: Active » Closed (duplicate)

Should be fixed now the whole anonymous checkout/duplicate emails/roles thing is all sorted in -dev.