Reproduced on clean installation.
It works when I just have "After saving a new user account" and either "User has role(s)" or "Set a data value". All tree together breaks user creation with error:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '24-4' for key 'PRIMARY': INSERT INTO {users_roles} (uid, rid) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 24 [:db_insert_placeholder_1] => 4 ) in user_save() (line 595 of /modules/user/user.module).
While testing I was always creating user from admin/people/create.
I figured out that actually roles that we are checking matters:
- creating 'authenticated'+'admin'; checking if has 'admin' - got error
- creating 'authenticated'; checking if has 'authenticated' - works ok
- creating 'authenticated'; checking if has any of 'authenticated', 'admin' - works ok
- creating 'authenticated'+'admin'; checking if has any of 'authenticated', 'admin' - got error
On developement site I've got the same error while checking for other roles
Comments
Comment #1
marcin.wosinek commentedIn user.module we have
So it seems that changing data in user entity activate the same function twice; and as we don't check if a role has been already added we get this error
Comment #2
marcin.wosinek commentedUser creation fail when created user has any additional role, and you change it's data. This is enough to run roles updating code twice.
Any way, as 'users_roles' table has only two columns, and both are primary key; there is absolutely no difference how many times we add the same stuff there.
Comment #3
marcin.wosinek commentedAfter investigating more this error, I see that rules implementation do it properly. The error is always when we are saving user with more then one role within entity_save implementation. So it should be fixed in user.module:
http://drupal.org/node/1433288