When cloning a blueprint space with both custom roles and overridden permissions, the custom roles are duplicated.

There are copied once by oa_clone in oa_clone.module:

function oa_clone_batch_clone_group_metadata($node, $original_nid, &$context) {
  […]

  // Clone OG roles.
  $original_role_map = array();
  $original_roles = og_roles('node', $node->type, $original_nid);
  foreach ($original_roles as $original_rid => $original_name) {
    $original_role_map[$original_name] = $original_rid;
    // If this is a custom role, then we have to create it.
    if (!in_array($original_name, array(OG_ANONYMOUS_ROLE, OG_AUTHENTICATED_ROLE, OG_ADMINISTRATOR_ROLE))) {
      $role = og_role_create($original_name, 'node', $node->nid, $node->type);
      og_role_save($role);
    }
  }

  […]
}

And once more in og.module by og_roles_override:

function og_entity_insert($entity, $entity_type) {
  […]
  if (!og_is_group_default_access($entity_type, $entity)) {
    // Override default roles.
    og_roles_override($entity_type, $bundle, $id);
  }
}

Commenting og_role_create/og_role_save fixes the issue.

Comments

A---- created an issue.