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

fl3a’s picture

Title: Assigning a policy to a role with the numeric id causes 'Integrity constraint violation' » Assigning a policy to a role with same the numeric id causes 'Integrity constraint violation'
erikwebb’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
StatusFileSize
new1.1 KB

I don't see anywhere that field is actually being used. I'd rather remove it entirely. Please confirm this patch works.

erikwebb’s picture

Priority: Normal » Critical
Issue tags: +D7 stable release blocker
erikwebb’s picture

I guess we should remove the unique key too...

matt v.’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new2.34 KB

I 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.

erikwebb’s picture

Status: Reviewed & tested by the community » Fixed

Thanks 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

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

Anonymous’s picture

Issue summary: View changes

corrected typo