Permissions in role ymls required?

Created on 27 May 2024, about 1 month ago
Updated 5 June 2024, 23 days ago

When exporting my Feature, I notice
1. permissions are added to role ymls
2. roles are added to permission ymls

I also noted that when installing my Feature module, 1 is required: Removing the permissions in those role ymls will result in the permissions not being set.

Is this correct behavior? I was hoping 1 is no longer required with this module.

It feels a bit redundant to have the permissions set in both ymls. I now only got it working by calling PermissionManager::syncRoleToPermissions for all my permissions.

πŸ’¬ Support request
Status

Active

Version

1.0

Component

Documentation

Created by

πŸ‡³πŸ‡±Netherlands koosvdkolk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @koosvdkolk
  • πŸ‡ΊπŸ‡ΈUnited States Chris Burge

    Is Features configured to export permissions with roles? It sounds like that is the issue.

  • πŸ‡³πŸ‡±Netherlands koosvdkolk

    My mistake.

    I enabled the "Strip out user permissions." and now the role ymls do not have the permissions anymore.

    So in my Feature, both the roles and (all) permissions are present. The role ymls do not contain permissions, the permission ymls contain roles. So far, so good. Nevertheless, the permissions are not added when I enable the Feature.

    What strikes me: If I enable my Feature and perform a 'drush fim' afterwards, it asks me to import the roles defined in the Feature.

    Could it be that for some reason, the roles are not imported yet at the moment the permissions get imported and hence, the permission assignment does not take place?

  • πŸ‡³πŸ‡±Netherlands koosvdkolk

    Diving into the code, and I do not understand how this module should work.

    * I have enabled features_permissions
    * I have a Feature containing the permissions AND the roles

    I enable the Feature.

    This is what happens: PermissionManager::syncRoleToPermissions is called for each new role in the Feature. Below arrays are all empty.

    $added_permissions = array_diff($permissions, $permissions_original)

    End result:
    * Roles are present
    * Permissions are present
    * No permissions are added to roles.

    So indeed my $0.02 would be that features_permissions tries receives the events in the wrong order in my use case: it tries to add yet-to-be-imported Feature permissions to Feature roles.

Production build 0.69.0 2024