Skip to content

[Console] Fix hasParameterOption / getParameterOption when used with multiple flags #25893

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

Merged
merged 1 commit into from
Feb 7, 2018

Conversation

greg-1-anderson
Copy link
Contributor

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:

@greg-1-anderson
Copy link
Contributor Author

AppVeyor build has an error in code not modified by this PR:

1) Symfony\Bundle\FrameworkBundle\Tests\Functional\SessionTest::testTwoClients with data set #0 ('config.yml', true)
RuntimeException: OUTPUT:  ERROR OUTPUT: 

Must be a transient failure, since https://ci.appveyor.com/project/fabpot/symfony/build/1.0.32162 passed.

@@ -168,12 +168,12 @@ private function parseArgument($token)
$arg = $this->definition->getArgument($c);
$this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token;

// if last argument isArray(), append token to last argument
// if last argument isArray(), append token to last argument
Copy link
Contributor

Choose a reason for hiding this comment

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

please revert this one, it's a wrong behaviour of fabbot

} elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
$arg = $this->definition->getArgument($c - 1);
$this->arguments[$arg->getName()][] = $token;

// unexpected argument
// unexpected argument
Copy link
Contributor

Choose a reason for hiding this comment

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

please revert this one, it's a wrong behaviour of fabbot

// If hasParameterOption('-fh') is supported for 'cli.php -fh', then
// one might also expect that it should also be supported for
// 'cli.php -f -h'. However, this is not supported.
$this->assertFalse($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
Copy link
Contributor

Choose a reason for hiding this comment

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

So you break the behaviour that was working with the patch IIUC?

Copy link
Member

Choose a reason for hiding this comment

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

If the patch breaks the existing and we can't manage to make both work, better revert it for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The patch does indeed have serious consequences for Drush, Robo, and potentially other clients as well. It is regrettable that get/hasParameterOptions do not have enough information available to handle multiple short options correctly.

@greg-1-anderson
Copy link
Contributor Author

Reverted the mistaken style patch.

@nicolas-grekas nicolas-grekas changed the title Fix hasParameterOption / getParameterOption when used with multiple flags [Console] Fix hasParameterOption / getParameterOption when used with multiple flags Jan 25, 2018
@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Jan 25, 2018
@chalasr chalasr self-requested a review January 26, 2018 05:18
@jakzal
Copy link
Contributor

jakzal commented Jan 26, 2018

👎

I'd rather revert the problematic patch (#24987) and see if we can fix that problem properly, or live with the limitation.

@fabpot
Copy link
Member

fabpot commented Jan 26, 2018

I think I agree with @jakzal. I'm going to revert #24987

@greg-1-anderson
Copy link
Contributor Author

@fabpot Thanks for backing out the previous commits. That will help considerably.

Note that this PR also fixes a bug in getParameterOption that has existed for a long time. Would you like that re-submitted as a separate PR, or would you prefer to live with the limitation?

@fabpot
Copy link
Member

fabpot commented Jan 29, 2018

@greg-1-anderson Can you rebase on current 2.7?

Add one test to demonstrate getParameterOption fix. Add several tests to demonstrate current limitations in hasParameterOption.
@greg-1-anderson
Copy link
Contributor Author

Rebased. The only remaining failure is the mistaken code style change suggested by fabbot, as mentioned above.

@fabpot
Copy link
Member

fabpot commented Feb 7, 2018

Thank you @greg-1-anderson.

@fabpot fabpot merged commit 35f98e2 into symfony:2.7 Feb 7, 2018
fabpot added a commit that referenced this pull request Feb 7, 2018
… 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.
@fabpot fabpot mentioned this pull request Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants