Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
fabpot merged 1 commit intosymfony:2.8fromwouterj:console_input_definition_event
Sep 30, 2015

Conversation

@wouterj
Copy link
Member

QA
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#10695 (problem 1)
LicenseMIT
Doc PR-

Previously,$input wasn't very usefull in theconsole.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 inCommand#run() (to allow changing the input definition in an event listener).

@stof
Copy link
Member

wouldn't this break cases where the command is allowing to get arguments interactively ininteract() ?

@wouterj
Copy link
MemberAuthor

@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
Copy link
MemberAuthor

Failures related to#15940 and not this PR

@xabbuh
Copy link
Member

@wouterj You could rebase as#15940 was merged (though we will still see some failures due to the security tests I think).

@Tobion
Copy link
Contributor

Please also add a test where the listener adds an option. And check if it can be used.

@Tobion
Copy link
Contributor

I was looking when validation actually happens as I sawsymfony/console#15.
It seems validation can happen both

@Tobion
Copy link
Contributor

wouldn't this break cases where the command is allowing to get arguments interactively in interact() ?

So this case from@stof doesn't break because

  • wrong arguments/options, e.g. too many would already error out when binding anyway
  • missing arguments can still be added in interact as the number of arguments is only validated later

@Tobion
Copy link
Contributor

Please also add a test where the listener adds an option. And check if it can be used.

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$input->bind(). So the listener won't have a chance to change the definition.

@Tobion
Copy link
Contributor

I think to solve the problem, we really need to refactor the validation.bind() should not validate but should parse everything indepently. And onlyvalidate checks if there are too many/missing/wrong arguments or options.

@wouterj
Copy link
MemberAuthor

@Tobion yeah, or wrap things inside a try..catch loop as is done in other bind cases. (not doing validation inbind() is a BC break).

@wouterj
Copy link
MemberAuthor

SoInput#validate() only validates if required arguments are passed.Input#bind() validates if passed options/arguments are valid. Added a try..catch loop around the binding before the event listener and added a test.

@wouterjwouterjforce-pushed theconsole_input_definition_event branch from8bd327f toc41899fCompareSeptember 28, 2015 21:11
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@wouterjwouterjforce-pushed theconsole_input_definition_event branch fromc41899f to0af1676CompareSeptember 30, 2015 12:45
@wouterj
Copy link
MemberAuthor

ping @symfony/deciders PR is now updated and ready to be merged imo

@Tobion
Copy link
Contributor

👍

Status: Reviewed

@xabbuh
Copy link
Member

👍

Should we add a changelog entry so that people interested in changing the definition notice this is possible now?

@fabpot
Copy link
Member

Thank you@wouterj.

@fabpotfabpot merged commit0af1676 intosymfony:2.8Sep 30, 2015
fabpot added a commit that referenced this pull requestSep 30, 2015
…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
@wouterjwouterj deleted the console_input_definition_event branchSeptember 30, 2015 20:37
@fabpotfabpot mentioned this pull requestNov 16, 2015
fabpot added a commit that referenced this pull requestMar 5, 2017
…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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@wouterj@stof@xabbuh@Tobion@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp