Closed (duplicate)
Project:
Rules
Version:
7.x-2.x-dev
Component:
Rules Core
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Jul 2011 at 15:29 UTC
Updated:
5 Dec 2012 at 16:57 UTC
If you perform more than one action on a new user, you get a "PDOException: SQLSTATE[23000]: Integrity constraint violation ... " in user_save() (... /modules/user/user.module)
Try it yourself:
Event - After saving a new user account
Action - Add user role
Action - Unblock a use (should be user?)
The above will cause an error, while having just one action won't.
Extra (similar) issues at: #1169800: [Integrity constraint violation: 1062 Duplicate entry] On user registration
Comments
Comment #1
SilviaT commentedSame issue for me.
Comment #2
fagoThe bug will be triggered as soon as you add a role after user creation and something issues a user-save(). I don't think we can do anything about it except for fixing it in core.
Comment #3
kristiaanvandeneyndeSo what does this mean for the issue itself?
Can it be fixed or do you suggest any sort of workaround?
Also: can't you create a queue system which only calls save_user() once (at the end of the queue) to prevent this issue?
Comment #4
altavis commentedsubscribing
Comment #5
kristiaanvandeneyndeAfter some testing, I've come to the conclusion that this bug is most likely due to the code in either Rules or Entity, not core.
The way Rules handles the $account variable seems to cause this behaviour.
To "fix" the above issue, I've come up with the following four actions (instead of two):
Parameter: Type: Integer, Value: [account:uid]
Provides variables: The user id (the_user_id)
Parameter: Entity type: User, Identifier: [the-user-id]
Provides variables: The user (the_user)
Parameter: User: [the-user]
Seeing as this kind of "resets" the user variable, it seems to me that Rules or Entity fail upon using the same variable multiple times.
Comment #6
fagosee http://drupal.org/node/1169800
Comment #7
pgancarski commentedBrilliant idea
But not working when I try to apply a rule that edits a newly created Node.