Block-specific permissions cannot be exported in Features

Created on 7 December 2018, over 6 years ago
Updated 26 March 2025, 10 days ago

No block-specific permissions are exported in Features, even when the relevant modules are checked under "Block Access" in the Features creation dialogue.

Looking at the Features export related code in the module, the reason is pretty clear: the block_access_get_module() function only selects items from the block_access_roles table with no delta set:

/**
 * get permissions for a given module
 * @param $module - the name of the module
 * @returns an array of Role IDs and their permissions
 */
function block_access_get_module($module) {
  $query = db_select('block_access_roles', 'b')
    ->fields('b', array('rid', 'permission'))
    ->condition('module', $module, '=')
    ->condition('delta', '', '=');

  $result = $query->execute();
  $ret = array();
  while ($ob = $result->fetchObject()) {
    if (isset($ret[$ob->rid])) {
      $ret[$ob->rid][] = $ob->permission;
    }
    else {
      $ret[$ob->rid] = array($ob->permission);
    }
  }
  return $ret;
}

This makes sense for module-specific permissions, but eliminates all block specific permissions (since the block delta is what makes a permission block-specific in the first place).

I followed some of the logic and played around a bit. The following steps got me a fair way along before I ran out of time to work on it:

  • Remove the `delta` condition in the query
  • Restructure the array returned by the function like this (where 'block' is the module that owns the block and '22' is the block delta):
      array(
        'block' => array(
          '22' => array(
            '4' => array(
              'config_title',
            ),
            '5' => array(
              'config_title',
              'config_body',
            ),
          ),
        ),
      ),
      
  • Modify the code that calls block_access_get_ so that it can extract info from the new structure.

All of this achieved part one of the solution (i.e. correctly exporting the values), but I had to stop before getting to the parts around enabling and reverting Features.

Not sure if I'll be able to come back to this, but wanted to document the issue and first steps to a fix.

🐛 Bug report
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

🇫🇷France bedlam Lyon

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.

  • 🇧🇪Belgium dieterholvoet Brussels

    Drupal 7 is EOL as of 5 January 2025 and so is the Drupal 7 version of this module. Marking as Closed (won't fix). Feel free to re-open if this issue is still present in any supported version of the module.

Production build 0.71.5 2024