-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] ArgvInput::hasParameterOption confused by short options with values #25825
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
Comments
@Simperfit your analysis here would be appreciated. |
Why should we revert #24987, it does fix a bug. We have to implement a method that will respect the consistency of both method and fix the bug by checking this format too. Do you want to try to fix this, I'm going to help you as I can ;). |
@Simperfit The In #25487, an attempt was made to fix a bug where someone using We cannot alter the implementation of I'd be happy to make a PR to revert #24987, or to make a PR to test just the first short option (instead of the old behavior of requiring short options appear by themselves when tested with |
I have another thought on how we might proceed here:
This will incur a slight performance penalty when using @fabpot You merged #25487, which I believe contained a logic error as explained above. Could you please review here and let me know if I have made any mistake in my analysis. I'd be happy to roll a PR to fix this once the desired remediation technique is agreed upon. |
@greg-1-anderson I've tested this behaviour on the whole supported version of symfony and I can't see where the According to my test it does nothing, it's not taken in account.
For the linked issue about Drush, could you please tell me what commands does it run with the -D options ? |
@Simperfit It seems like the We do support passing values to short options with no separator.
Output:
Note that there is no output for the third Short option with value and no separator is tested here https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php#L112 and is still green on all maintained branches. We need to fix the |
@chalasr Thank you for the feedback. The existing unit test you reference above is in fact passing; it happens to not hit one of the non-working edge cases. I can provide a PR with a failing unit test and a failing integration test to illustrate the problem here. |
@chalasr Please see the failing tests in #25852; hopefully this will clarify how the API was intended to behave vs. its actual behavior before and after #24987 @Simperfit Drush / Robo / Phing support defining configuration items on the commandline. For example, the following config file:
Could also be represented on the command line:
|
…arameterOption.
Proposed fix in #25893 |
Just noticed Behat tests are failing because of this issue (see here). The following command started displaying a help message, instead of running the test suite:
The cause of the issue is #24987 and reverting it would solve the problem. symfony/src/Symfony/Component/Console/Application.php Lines 164 to 172 in 7b4d519
|
I think #25893 is ready to go; hopefully we can get that into some stable Symfony releases shortly. |
Add one test to demonstrate getParameterOption fix. Add several tests to demonstrate current limitations in hasParameterOption.
… used with multiple flags (greg-1-anderson) This PR was merged into the 2.7 branch. Discussion ---------- [Console] Fix hasParameterOption / getParameterOption when used with multiple flags | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no (Fixes BC break in #24987) | Deprecations? | no | Tests pass? | yes | Fixed tickets | #25825 | License | MIT | Doc PR | n/a Proposed resolution to #25825: - Back out #24987 - Fix getParameterOption for short options with values, e.g. `-edev` Commits ------- 35f98e2 Follow-on to #25825: Fix edge case in getParameterOption.
* 2.7: [SecurityBundle] Backport test Fix misspelling variable [DI] minor: use a strict comparision in setDecoratedService Follow-on to #25825: Fix edge case in getParameterOption. keep the context when validating forms
* 2.8: [SecurityBundle] Backport test [Security] fix merge of 2.7 into 2.8 + add test case backport regression test from 3.4 Fix misspelling variable [DI] minor: use a strict comparision in setDecoratedService Follow-on to #25825: Fix edge case in getParameterOption. keep the context when validating forms
* 3.4: Env var maps to undefined constant. [SecurityBundle] Backport test [Security] fix merge of 2.7 into 2.8 + add test case backport regression test from 3.4 do not mock the container builder or definitions fixed CS [TwigBundle] Register TwigBridge extensions first [WebProfilerBundle] Fix sub request link PhpDocExtractor::getTypes() throws fatal error when type omitted Fix misspelling variable use libsodium to run Argon2i related tests [DI] minor: use a strict comparision in setDecoratedService [HttpKernel] fix FC Follow-on to #25825: Fix edge case in getParameterOption. keep the context when validating forms
* 4.0: fix merge Env var maps to undefined constant. [SecurityBundle] Backport test [Security] fix merge of 2.7 into 2.8 + add test case backport regression test from 3.4 do not mock the container builder or definitions fixed CS [TwigBundle] Register TwigBridge extensions first [WebProfilerBundle] Fix sub request link PhpDocExtractor::getTypes() throws fatal error when type omitted Fix misspelling variable use libsodium to run Argon2i related tests [DI] minor: use a strict comparision in setDecoratedService [HttpKernel] fix FC Follow-on to #25825: Fix edge case in getParameterOption. keep the context when validating forms
* 3.4: Env var maps to undefined constant. [SecurityBundle] Backport test [Security] fix merge of 2.7 into 2.8 + add test case backport regression test from 3.4 do not mock the container builder or definitions fixed CS [TwigBundle] Register TwigBridge extensions first [WebProfilerBundle] Fix sub request link PhpDocExtractor::getTypes() throws fatal error when type omitted Fix misspelling variable use libsodium to run Argon2i related tests [DI] minor: use a strict comparision in setDecoratedService [HttpKernel] fix FC Follow-on to symfony#25825: Fix edge case in getParameterOption. keep the context when validating forms
* 4.0: fix merge Env var maps to undefined constant. [SecurityBundle] Backport test [Security] fix merge of 2.7 into 2.8 + add test case backport regression test from 3.4 do not mock the container builder or definitions fixed CS [TwigBundle] Register TwigBridge extensions first [WebProfilerBundle] Fix sub request link PhpDocExtractor::getTypes() throws fatal error when type omitted Fix misspelling variable use libsodium to run Argon2i related tests [DI] minor: use a strict comparision in setDecoratedService [HttpKernel] fix FC Follow-on to symfony#25825: Fix edge case in getParameterOption. keep the context when validating forms
#24987 introduced a bug in hasParameterOption. If a short option has a value, then hasParameterOption will search the value for additional short options.
#25487 submitted a fix for this bug, but the fix appears to be incorrect.
The current implementation of
parseShortOption
is as follows:In particular, note the
substr($name, 1)
. If there is a short option-e
that takes a value, then-etest
will provide the valuetest
to the-e
option. See also the implementation ofparseShortOptionSet
, which has similar logic. No=
is assumed or accounted for.#25487 fixed the bug of #24987 by assuming that the value of a short option was formatted as
-e=test
; however, this is inconsistent with the implementation of the parsing functions.My testing seems to uphold these observations, but please LMK if I have made an error somewhere. I'm not sure if there is a better solution than reverting #24987.
The text was updated successfully, but these errors were encountered: