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

[user:create] shows error when --roles is specified. #4133

Closed
ndouglas opened this issue Aug 20, 2019 · 0 comments
Closed

[user:create] shows error when --roles is specified. #4133

ndouglas opened this issue Aug 20, 2019 · 0 comments

Comments

@ndouglas
Copy link
Contributor

Problem/Motivation

We see an error like this:

[ERROR] <em class="placeholder">Warning</em>: implode(): Invalid arguments passed in <em                               
         class="placeholder">Drupal\Console\Command\User\CreateCommand-&gt;createUser()</em> (line <em                  
         class="placeholder">249</em> of <em                                                                            
         class="placeholder">/var/www/drupalvm/vendor/drupal/console/src/Command/User/CreateCommand.php</em>). <pre     
         class="backtrace">Drupal\Console\Command\User\CreateCommand-&gt;createUser(&#039;username&#039;,             
         &#039;password&#039;, &#039;role&#039;, NULL, &#039;1&#039;) (Line: 119)                               
         Drupal\Console\Command\User\CreateCommand-&gt;execute(Object, Object) (Line: 255)                              
         Symfony\Component\Console\Command\Command-&gt;run(Object, Object) (Line: 987)                                  
         Symfony\Component\Console\Application-&gt;doRunCommand(Object, Object, Object) (Line: 255)                     
         Symfony\Component\Console\Application-&gt;doRun(Object, Object) (Line: 188)                                    
         Drupal\Console\Core\Application-&gt;doRun(Object, Object) (Line: 64)                                           
         Drupal\Console\Application-&gt;doRun(Object, Object) (Line: 148)                                               
         Symfony\Component\Console\Application-&gt;run() (Line: 89)                                                     
         require(&#039;/var/www/drupalvm/vendor/drupal/console/bin/drupal.php&#039;) (Line: 4)                          
         </pre>     

How to reproduce

Attempt to create a user with the following syntax:

drupal user:create <username> <password> --roles="<role>" --status=1 --no-interaction

Details to include:

  • Drupal version: 8.7.6
  • Console version: v1.9.0

Solution

It looks like the roles option isn't transformed into an array at any point if it is provided as an argument. However, in createUser, after the user is created, the code assumes that the $roles variable is an array and tries to implode it, which causes an error to be thrown while populating $result['success'], which then results in a nasty backtrace.

I'll submit a pull request here in a bit.

ndouglas added a commit to ndouglas/drupal-console that referenced this issue Aug 20, 2019
This prevents an error from being thrown when constructing the success message.  See hechoendrupal#4133.
enzolutions pushed a commit that referenced this issue Sep 6, 2019
This prevents an error from being thrown when constructing the success message.  See #4133.
enzolutions pushed a commit that referenced this issue Oct 10, 2019
* Update services.yml

* Fix Travis tests

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* 1

* Ensure $roles is an array when creating users. (#4134)

This prevents an error from being thrown when constructing the success message.  See #4133.

* Generate revisional entity content is broken (#4139)

* Add bundle permissions for content entity (#4138)

* Add command option has-bundle-permissions and use on entity.

* Add (Entity}Permissions.php file.

* Add permission_callback to permissions.yml file.

* Added fix from #4139 as it hurts.

* Add own permissions checks.

* Add --default option to database:add (#4143)

This option allows to set the database as the default one instead of
adding a new database in addition to the default one.

See: #4142

* Update version to 1.9.3 (#4144)

* Update version to 1.9.3

* Remove Module/InstallCommand::moduleRequirement

* Remove
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

No branches or pull requests

2 participants