E.g. trying to assign policy with policy id 2 to role with role id 2:
Ocurs when
- Creating the policy and try to assign the role(s) in this step
- trying to assign the role to a existing policy
The name row in table password_policy_role might consist of $pid.'-'.$rid and must not be empty?
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2-' for key 'name': INSERT INTO {password_policy_role} (pid, rid) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 2 [:db_insert_placeholder_1] => 2 ) in password_policy_admin_form_submit() (Zeile 444 von /xxx/drupal/stein-stein.de/drupal/sites/default/modules/password_policy/password_policy.admin.inc).
Attached patch fixes above the exception and let you assign roles to policies with the same numeric id´s.
THX to 'leon der profi' for prividing this patch!
Comments
Comment #1
fl3a commentedComment #2
erikwebb commentedI don't see anywhere that field is actually being used. I'd rather remove it entirely. Please confirm this patch works.
Comment #3
erikwebb commentedComment #4
erikwebb commentedI guess we should remove the unique key too...
Comment #5
matt v. commentedI wrote a quick-and-dirty test case to recreate the issue. The test confirmed the issue. I then applied the patch and re-ran the test, which confirmed the fix.
I'm attaching a patch containing the test, in case it's helpful. It may not make sense to add it to the test file permanently though.
Comment #6
erikwebb commentedThanks for the test, but I believe you're right. We shouldn't be adding tests just to make sure old bugs don't crop up.
http://drupalcode.org/project/password_policy.git/commit/f9c8db6
Comment #7.0
(not verified) commentedcorrected typo