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

[5.5] Check for --no-interaction flag on command calls #22515

Merged
merged 3 commits into from
Dec 26, 2017
Merged

[5.5] Check for --no-interaction flag on command calls #22515

merged 3 commits into from
Dec 26, 2017

Conversation

Miguel-Serejo
Copy link

Currently, calling an artisan command from another artisan command as described in the docs ($this->call(...)) does not allow the --no-interaction flag to be set on the command (or rather, you can set it, but it won't have any effect unless the called command specifically checks for it).
The current workaround is to use the Artisan facade.

This was raised in the Adldap2-Laravel repo:
Adldap2/Adldap2-Laravel#441 (comment)

This PR solves the issue by explicitly checking for the --no-interaction flag (but not the shorthand -n flag) to set the interactive mode of the new input in the same manner symfony/application sets it in Application::configureIO:
https://github.com/symfony/symfony/blob/07766b39052b6ba294dc6ddf85e38ee61a8e0bcb/src/Symfony/Component/Console/Application.php#L791-L792

An alternative would be to check if the current command is being run in non-interactive mode, but I think that would have a higher chance of breaking existing code. This way, the only way to break existing code is if someone is using the --no-interaction argument in a command call and somehow still expecting interaction.
Avoiding BC breaks is also the reason I've omitted the -n short syntax, as it is plausible that people may have developed commands that are being called exclusively by other commands and have their own meaning for -n without knowing it's intended purpose.

Currently, calling an artisan command from another artisan command as described in the docs (`$this->call(...)`) does not allow the `--no-interaction` flag to be set on the command (or rather, you can set it, but it won't have any effect unless the called command specifically checks for it).
The current workaround is to use the `Artisan` facade. 

This was raised in the Adldap2-Laravel repo: 
Adldap2/Adldap2-Laravel#441 (comment)

This PR solves the issue by explicitly checking for the `--no-interaction` flag (but not the shorthand `-n` flag) to set the interactive mode of the new input in the same manner symfony/application sets it in `Application::configureIO`: 
https://github.com/symfony/symfony/blob/07766b39052b6ba294dc6ddf85e38ee61a8e0bcb/src/Symfony/Component/Console/Application.php#L791-L792

An alternative would be to check if the current command is being run in non-interactive mode, but I think that would have a higher chance of breaking existing code. This way, the only way to break existing code is if someone is using the `--no-interaction` argument in a command call and somehow still expecting interaction.  
Avoiding BC breaks is also the reason I've omitted the `-n` short syntax, as it is plausible that people may have developed commands that are being called exclusively by other commands and have their own meaning for `-n` without knowing it's intended purpose.
@GrahamCampbell GrahamCampbell changed the title Check for --no-interaction flag on command calls [5.5] Check for --no-interaction flag on command calls Dec 22, 2017
@taylorotwell taylorotwell merged commit 76c9db0 into laravel:5.5 Dec 26, 2017
@Miguel-Serejo Miguel-Serejo deleted the patch-1 branch December 26, 2017 14:53
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.

3 participants