Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drush role:create is broken #5117

Closed
marcvangend opened this issue Apr 7, 2022 · 6 comments · Fixed by #5118
Closed

Drush role:create is broken #5117

marcvangend opened this issue Apr 7, 2022 · 6 comments · Fixed by #5118

Comments

@marcvangend
Copy link

The bug / steps to reproduce
When I ran $ drush role:create 'some role' I got:

 [error]  AssertionError: Role label is expected to be a string. in assert() (line 851 of /Users/me/project/web/core/modules/user/user.module) #0 /Users/me/project/web/core/modules/user/user.module(851): assert(false, 'Role label is e...')`

And then a bunch of debugging info (stack trace).

After this, I could not see the new role in the admin UI. But when trying the command again (this time with two arguments, as should also work), it said:

In EntityStorageBase.php line 557:

  'user_role' entity with ID 'some role' already exists.

Expected behavior
The new role is created and available in the admin UI.

Actual behavior
See above.

Workaround
Create the role from the admin UI.

System Configuration

Q A
Drush version? 11.0.7
Drupal version? 9.3.9
PHP version 8.0.12
OS? MacOS

Additional information
This happened to me when following the instructions at https://next-drupal.org/learn/quick-start. A couple of contrib modules and two patched had already been installed at this point, but I don't think that is causing the problem.

@gitressa
Copy link
Contributor

gitressa commented Apr 7, 2022

I can confirm this behavior in a fresh install. It's only if I add two parameters the first time the command is run, that the role gets created as expected:

$ drush role:create 'test role 2' 'Test role 2'
[success] Created "test role 2"

A side note: When supplying two parameters, the user role is created, but the machine name has spaces in it, i.e. test role 2, in stead of as expected test_role_2, like for example the default Content editor role, with content_editor.

Perhaps something to look at in another issue, only allowing _, a-z and 0-9 in the machine name?

System Configuration

Q A
Drush version 11.0.7
Drupal version 9.3.9
PHP version 8.0.17
OS Ubuntu 20.04.4 LTS

@weitzman
Copy link
Member

weitzman commented Apr 7, 2022

Looks like this started happening in drupal 9.3 with https://www.drupal.org/node/3232673. I think drush should just require both arguments. I'll make a PR soon.

@weitzman
Copy link
Member

weitzman commented Apr 7, 2022

I was able to keep the feature where you only provide a machine name. Its now undocumented and deprecated. Please pass both params going forward. See #5118

Drush doesn't try to improve your provided machine name. I think thats reasonable.

@gitressa
Copy link
Contributor

gitressa commented Apr 7, 2022

Thanks, I tested the update, and it works well.

@marcvangend
Copy link
Author

That was fast, thank you!

@gitressa
Copy link
Contributor

gitressa commented Apr 8, 2022

Thank you for reporting it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants