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.
Considering the fact that most modules define permissions with spaces in them, this is pretty useless without this working. Fortunately, the fix for it is pretty easy. I don't know the best way to create a patch so I am just putting the updated drush_permissions_api_perm_grant() function here and hoping someone can create the actual patch for it.
function drush_permissions_api_perm_grant() {
$args = func_get_args();
$role = $args[0];
array_shift($args);
// The $args array splits command line arguments on the spaces. Permissions may have spaces in them and are to be entered in a comma separated list.
$perms = explode(',', implode(' ', $args));
$module = drush_get_option('module');
if ($module) {
permissions_grant_all_permissions_by_module($role, $module);
drush_print(dt('Granted all !module permissions to !role.', array('!module' => $module, '!role' => $role)));
}
elseif ($perms[0] == 'all') {
permissions_grant_all_permissions($role);
drush_print(dt('All permissions granted to !role.', array('!role' => $role)));
}
else {
permissions_grant_permissions($role, $perms);
drush_print(dt('Specified Permissions granted to !role.', array('!role' => $role)));
}
}
I think that the perm-revoke command probably needs a similar fix. I tested the above and it worked for me.
Comments
Comment #1
ebeyrent CreditAttribution: ebeyrent commentedThanks, and good find. I'll take a look at this as soon as I can.
Comment #2
Ken Wolf CreditAttribution: Ken Wolf commentedSingle quotes can be used, in the cmd line invocation of this drush command, to get the existing code to handle permissions with spaces.
-Ken Wolf
Comment #3
doublejosh CreditAttribution: doublejosh commentedThis doesn't work for me.
INPUT: drush perm-grant 'anonymous user' access_devel_information --uri=mysite.local
ERROR: The drush command 'perm-grant anonymous user access_devel_information' could not be found.
Comment #4
doublejosh CreditAttribution: doublejosh commented...and my fault.
1) Didn't realize I had to enable the module, thought I could just make use of the API functions.
http://drupal.org/node/897774
2) Thought I needed to change spaced to underscores in permissions, nope.
COMMAND: drush perm-grant 'anonymous user' 'access devel information' --uri=mysite.local
Thanks for the this awesome module!
My environment workflow just got more smooth.
Comment #5
ebeyrent CreditAttribution: ebeyrent commented