Skip to content

Fix #4541: Add again uid and mail options for user commands#4542

Merged
weitzman merged 4 commits intodrush-ops:11.xfrom
obriat:fix/4541
Dec 15, 2021
Merged

Fix #4541: Add again uid and mail options for user commands#4542
weitzman merged 4 commits intodrush-ops:11.xfrom
obriat:fix/4541

Conversation

@obriat
Copy link
Contributor

@obriat obriat commented Aug 27, 2020

Fix #4541: Add again uid and mail options for user command.

@q0rban
Copy link

q0rban commented Dec 7, 2021

This would be nice!

@q0rban
Copy link

q0rban commented Dec 7, 2021

As a workaround, you can do things like this:

vendor/bin/drush user:block "$(vendor/bin/drush user:information --uid=1 --fields=name --format=string)"

@deviantintegral
Copy link
Contributor

We discussed the above, and one issue we have is that it's not very discoverable for junior developers or those unfamiliar with the shell. Making it an argument exposes it in the help docs, where the above requires understanding of shell string substitution.

@weitzman I see you closed the related issue. Is there anything you would like to see in order to get a feature like this merged in?

@weitzman
Copy link
Member

In general, this looks great. I am looking at our more strict validation in user:login and wondering if the warnings proposed here are sufficient. See

$account = null;
if (!is_null($options['name']) && !$account = user_load_by_name($options['name'])) {
throw new \Exception(dt('Unable to load user by name: !name', ['!name' => $options['name']]));
}
if (!is_null($options['uid']) && !$account = User::load($options['uid'])) {
throw new \Exception(dt('Unable to load user by uid: !uid', ['!uid' => $options['uid']]));
}
if (!is_null($options['mail']) && !$account = user_load_by_mail($options['mail'])) {
throw new \Exception(dt('Unable to load user by mail: !mail', ['!mail' => $options['mail']]));
}
if (empty($account)) {
$account = User::load(1);
}

@weitzman weitzman changed the title Fix #4541: Add again uid and mail options for user command. Fix #4541: Add again uid and mail options for user commands Dec 15, 2021
@weitzman weitzman changed the base branch from 10.x to 11.x December 15, 2021 13:28
@weitzman weitzman closed this Dec 15, 2021
@weitzman weitzman reopened this Dec 15, 2021
@weitzman
Copy link
Member

Sorry for the notification noise while I coax CircleCI run its tests on this PR.

@weitzman weitzman merged commit 2270b5b into drush-ops:11.x Dec 15, 2021
@miromichalicka
Copy link

@weitzman sorry to bother you, but could this be backported to 10.x as well since it's still a stable release? Seems to be mergeable without any changes.

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 this pull request may close these issues.

Re implement uid & mail options for user:* commands

5 participants