An update from 7.x-4.1 to 7.x-4.5 fails with the following error message.

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3-administer autologout' for key 'PRIMARY'

A look in the role table reveals the following entries:

permission administer autologout

permission administer autologout

The db_update looks like this:

/**
 * Fix permission names in role_permission table
 */
function autologout_update_7401() {
  db_update('role_permission')
    ->fields(array('permission' => 'administer autologout'))
    ->condition('permission', 'auto administer autologout', '=')
    ->execute();
}

there are no other corresponding updates to this table in the install file.

Those are our featured permissions:

// Exported permission: 'administer autologout'.
  $permissions['administer autologout'] = array(
    'name' => 'administer autologout',
    'roles' => array(
      'administrator' => 'administrator',
      'testrole' => 'testrole',
    ),
    'module' => 'autologout',
  );
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

macdev_drupal created an issue. See original summary.

macdev_drupal’s picture

FileSize
0 bytes
macdev_drupal’s picture

Issue summary: View changes
FileSize
5.63 KB
macdev_drupal’s picture

Issue summary: View changes
stefan.korn’s picture

Assigned: Unassigned » stefan.korn
Related issues: +#2389845: Autologout permission renamed

This is related to: https://www.drupal.org/project/autologout/issues/2389845

Patch introduced there does not account for the case that the permissions "auto administer autologout" and "administer autologout" with the same "rid" do already exist in the table "role_permission" and can therefore lead to this MYSQL integrity constraint violation error. In this case the permission "auto administer autologout" should not be renamed (which in fact is not possible then) but rather be deleted.

Will provide a patch for this.

stefan.korn’s picture

This patch fixes the issue.

stefan.korn’s picture

Assigned: stefan.korn » Unassigned
Status: Active » Needs review