Permissions are lost on feature revert for node type

Created on 9 September 2015, about 10 years ago
Updated 25 September 2025, 11 days ago

When you revert node type feature component, it triggers nodeaccess_node_type_insert() and as result it wipes all defined permissions.

During revert features removes node type and then insert new one. That's why nodeaccess_node_type_insert() is triggered. We need to check existing permissions for node type instead of creating new ones.
features.node.inc

function node_features_revert($module = NULL) {
  if ($default_types = features_get_default('node', $module)) {
    foreach ($default_types as $type_name => $type_info) {
      // Delete node types
      // We don't use node_type_delete() because we do not actually
      // want to delete the node type (and invoke hook_node_type()).
      // This can lead to bad consequences like CCK deleting field
      // storage in the DB.
      db_delete('node_type')
        ->condition('type', $type_name)
        ->execute();
    }
    node_types_rebuild();
    menu_rebuild();
  }
}

How to reproduce

1. Configure permissions for node type
2. Export node type into feature
3. Change node type name or description.
4. Revert features.

Result:

All permissions from step 1 will be removed.

Expected behavior:

Permissions should remain the same.

πŸ› Bug report
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States sanchiz

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024