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 9 converts command arguments as command aliases #3054

Closed
fgm opened this issue Oct 11, 2017 · 6 comments
Closed

Drush 9 converts command arguments as command aliases #3054

fgm opened this issue Oct 11, 2017 · 6 comments
Assignees

Comments

@fgm
Copy link
Contributor

fgm commented Oct 11, 2017

When passing arguments named like existing command aliases, they are converted to the full name of the command.

Example:

  • drush en fr foo passes [‘fr’, ‘foo’] to the command,
  • drush en fr en passes [‘fr’, ‘pm-enable’] to the command, expanding the parameter as if it was a command alias

Also happens when using drush_invoke_process():

  • drush_invoke_process('@self', 'language:export:translation', ['fr', $file], $exportOptions) invokes exportTranslations() with fr
  • drush_invoke_process('@self', 'language:export:translation', ['en', $file], $exportOptions) invokes exportTranslations() with pm-enable
@greg-1-anderson
Copy link
Member

Ooops.

Drush has a feature in the preflight to convert from old-style flags, e.g. --ssh-options to the equivalent new form, e.g. -Dssh.options. The feature was used to convert the command shortcut en to pm-enable, because Symfony will not disambiguate the en shortcut between other commands with similar embedded patterns. Unfortunately, the existing preflight conversion mechanism is indiscriminate about the position of the items it is converting.

We need to either remove this conversion, or enhance it so that it only converts command aliases if they appear in the Drush command position.

@weitzman
Copy link
Member

Nice debugging.

I dont think we can remove this conversion. The muscle memory for 'en' is large.

Right now, the only arguments affected by this would be 'en' and 'si'. So, its probably just language modules that would feel the pain. If drush-language not use that literal argument, that would be ideal. Otherwise, a Drush PR which makes us only remap command name would be appreciated. See

'en' => 'pm-enable',

@fgm
Copy link
Contributor Author

fgm commented Oct 11, 2017

Also maybe "fr" too: it's features-revert which is likely to be used quite a bit too. And there are probably many more. but not sure it belongs here.

@weitzman
Copy link
Member

weitzman commented Oct 11, 2017 via email

@greg-1-anderson
Copy link
Member

Not every two-letter command alias is a problem; Symfony would only have trouble with fr if there were a lot of other commands that begin with fr. This may or may not be the case.

We currently do not have a mechanism for commands to extend the preflight conversion. There is no way we could support that, as preflight happens very early, and command hooks do not get loaded until much later.

@greg-1-anderson
Copy link
Member

This still needs to be fixed.

@greg-1-anderson greg-1-anderson self-assigned this Oct 14, 2017
greg-1-anderson added a commit that referenced this issue Oct 14, 2017
…y appear as the first non-option / non-alias parameter on the argv list.
greg-1-anderson added a commit that referenced this issue Oct 16, 2017
* Fixes #3054: Only replace command aliases (e.g. 'en' + 'si') when they appear as the first non-option / non-alias parameter on the argv list.

* Fixes #2918: Add site-specific search paths (__DRUPAL_ROOT__/drush and __PROJECT_ROOT__/drush) where commandfiles may be found.

* Fix problem with bootstrapping w/ no site.
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

3 participants