Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When exporting user roles, FeatureManager::addPackageFile() removes the permissions of the exported role:
// User roles include all permissions currently assigned to them. To
// avoid extraneous additions, reset permissions.
if ($config->getType() == 'user_role') {
$data = $config->getData();
// Unset and not empty permissions data to prevent loss of configured
// role permissions in the event of a feature revert.
unset($data['permissions']);
$config->setData($data);
}
Reading the comments, the behaviour seems unintentional. Shouldn't it be possible to export user roles together with the assigned permissions?
How to reproduce:
- assign permissions to a role
- export the role to a feature
- expected behaviour: "permissions: ..." in the yml file, just like the export using config:export
- actual behaviour: permissions are stripped from the yml file
Comments
Comment #2
nedjoThis is a frequently posted issue. See #2726409: Why permissions are not exported with roles?, #2383439: User permission handling, #2613850: Roles permissions not written.
The change that would be needed is in issue #2599278: Move export processing to a configurable plugin. Patches there appreciated.
Comment #3
jsst CreditAttribution: jsst at Ibuildings commentedDon't know how I did not see those issues, thanks for the prompt response!
Comment #4
nedjoNo prob. I've just posted a patch on #2599278: Move export processing to a configurable plugin. Testing and reviews appreciated.