Basic D6 installation upgraded to latest D7-dev snapshot. Non error messages during the upgrade process but when I try to change any settings in admin/people/permissions I get this fatale error:

PDOException: 
SQLSTATE[23000]: 
Integrity constraint violation: 1062 Duplicate entry 
'3-administer contact forms' for key 'PRIMARY': 
INSERT INTO 
    {role_permission} 
    (
    rid
  , permission
  , module
    ) 
VALUES 
    (
    :db_insert_placeholder_0
  , :db_insert_placeholder_1
  , :db_insert_placeholder_2
  )
; 
  
Array ( 
  [:db_insert_placeholder_0] 
    => 3 [:db_insert_placeholder_1] 
    => administer contact forms [:db_insert_placeholder_2] 
    => contact 
  )  
in user_role_grant_permissions() (line 2875 of drupal/modules/user/user.module

Have taken the liberty to reformat the error message to improve readability. Pls let me know if you would rather like the untouched version. The upgrade script rapported this:

Update #7007
* Inserted into {role_permission} the permissions for role ID 1, Inserted into {role_permission} the permissions for role ID 2, Inserted into {role_permission} the permissions for role ID 3

Could the problem be related to system_update_7007? Rebuilding the permissions from admin did not fix it either.

Tagging this as critical instead as major then this is pretty hard to use the site without a proper user role system though it looks like the security is still is maintained.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David_Rothstein’s picture

I think this is related to #607238: Permissions are assumed to be unique among modules, but uniqueness is not enforced, especially the last set of comments after the issue was reopened. I agree it is a critical bug.

JacobSingh’s picture

Indeed, this is bad. The module field should not be part of the primary keys.

I'll roll a patch

David_Rothstein’s picture

I believe there is already a patch being discussed at the issue I linked to. Maybe this is a duplicate (although that other issue is not titled in a way that anyone with this problem will ever find it).

JacobSingh’s picture

Status: Active » Needs review
FileSize
423 bytes
JacobSingh’s picture

Title: D6 to D7: Getting an integrity constraint violation: 1062 Duplicate entry i user.module » user_role_grant_permissions throws a primary key violation when it should do a merge
moshe weitzman’s picture

Status: Needs review » Closed (duplicate)

I agree that this is a dupe. Join us over there.