[6.x] Check no-interaction flag exists and is true for Artisan commands #33950
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Go easy on me, this is my first contribution to open source.
This PR was made because I noticed a bug with the way that the CallsCommand concern handles how it checks if the command should be run with no-interaction i.e. does not prompt for user input.
It currently only checks if the option is present, rather than checks if it is true or false in the input array. So, rather than
hasParameterOption
increateInputFromArguments
, I changed it togetParameterOption
which still returns false if the option is not present. If not present === false; present in terminal === true; present but value is false === false.I reproduced this bug when calling a deprecated Artisan command in a Laravel package which passed all of the arguments and options to the new Artisan command via
$this->call(...)
, PSB an example.With this array of options, it passes a default value for no-interaction which is false. In its current state, the framework will take that option as: you want no prompt to appear as it runs through the command.
Here is an example of the real command that should prompt for input, but would not:
Thank you for taking the time to review this. I hope I have explained this clearly enough.