Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Console] Bind input before executing the COMMAND event#15938
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
stof commentedSep 27, 2015
wouldn't this break cases where the command is allowing to get arguments interactively in |
wouterj commentedSep 27, 2015
@stof afaics, this only binds, the validation is still done after interact. So I don't think it should cause trouble. It also means listeners can add options/arguments without getting validation errors. |
wouterj commentedSep 27, 2015
Failures related to#15940 and not this PR |
xabbuh commentedSep 27, 2015
Tobion commentedSep 27, 2015
Please also add a test where the listener adds an option. And check if it can be used. |
Tobion commentedSep 28, 2015
I was looking when validation actually happens as I sawsymfony/console#15.
|
Tobion commentedSep 28, 2015
So this case from@stof doesn't break because
|
Tobion commentedSep 28, 2015
I think exactly that is still no possible with this solution. If you call a command with an option/argument that is only about to be added by a listener, it will throw an exception already when trying to parse the input via |
Tobion commentedSep 28, 2015
I think to solve the problem, we really need to refactor the validation. |
wouterj commentedSep 28, 2015
@Tobion yeah, or wrap things inside a try..catch loop as is done in other bind cases. (not doing validation in |
wouterj commentedSep 28, 2015
So |
8bd327f toc41899fCompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think it would be easiest to just catch allSymfony\Component\Console\Exception\ExceptionInterface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
similarlyhttps://github.com/symfony/symfony/blob/2.8/src/Symfony/Component/Console/Command/Command.php#L234 should be updated
c41899f to0af1676Comparewouterj commentedSep 30, 2015
ping @symfony/deciders PR is now updated and ready to be merged imo |
Tobion commentedSep 30, 2015
👍 Status: Reviewed |
xabbuh commentedSep 30, 2015
👍 Should we add a changelog entry so that people interested in changing the definition notice this is possible now? |
fabpot commentedSep 30, 2015
Thank you@wouterj. |
…t (WouterJ)This PR was merged into the 2.8 branch.Discussion----------[Console] Bind input before executing the COMMAND event| Q | A| ------------- | ---| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#10695 (problem 1)| License | MIT| Doc PR | -Previously, `$input` wasn't very usefull in the `console.command` event, as the input was not yet bound to the command definition.With this PR, the input is now bound twice: Once before the event is dispatched (to make it usefull in the listeners) and once at the original location in `Command#run()` (to allow changing the input definition in an event listener).Commits-------0af1676 Bind input before executing the COMMAND event
…mmand event (chalasr)This PR was merged into the 2.8 branch.Discussion----------[Console] Do not squash input changes made from console.command event| Q | A| ------------- | ---| Branch? | 2.8| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#19441| License | MIT| Doc PR | n/aSetting arguments/options from the `console.command` event is expected to work since#15938Commits-------c8d364b [Console] Do not squash input changes made from console.command event
Previously,
$inputwasn't very usefull in theconsole.commandevent, as the input was not yet bound to the command definition.With this PR, the input is now bound twice: Once before the event is dispatched (to make it usefull in the listeners) and once at the original location in
Command#run()(to allow changing the input definition in an event listener).