I frequently see this sequence of errors in my log:
query: INSERT INTO users (pass, created, changed, uid) VALUES ('69a6a7785376c768a8b6ee', '1132072196', '1132072196', '704') in /web/drupal/includes/database.pgsql.inc on line 62.
pg_query() [function.pg-query]: Query failed: ERROR: duplicate key violates unique constraint "users_name_key" in /web/drupal/includes/database.pgsql.inc on line 45.
Invalid argument supplied for foreach() in /web/drupal/modules/user.module on line 174.
and then the message: Password mailed to at .
I finally discovered this occurs when an anon user requests a new password (user/password) but does not have an account or types it incorrectly. Drupal actually comes back and says the password has been sent.
The problem is in the assignments for $account in function user_pass:
$account = user_load(array('name' => $edit['name'], 'status' => 1))
This returns an empty object, not null. From my log:
[Tue Nov 15 11:35:09 2005] [error] stdClass Object\n(\n)\n
So the later test for if ($account) is true when in fact there is no such account.
Environment: PostgreSQL 8.0.4; PHP 5.0.4.
Comments
Comment #1
rossg commentedSame here, different database backend (drupal 4.6.5 w/mysql 4.1). Also happening when requesting a password reminder.
user error: Duplicate entry '' for key 2
query: INSERT INTO users (pass, created, changed, uid) VALUES ('3eb84bfcdb08a941130be212bbac8904', '1133445219', '1133445219', '2') in /home/rossg/clients/golder/drupal-wd/includes/database.mysql.inc on line 66.
Comment #2
Bèr Kessels commentedDuplicate of http://drupal.org/node/41317