bug #22027 Revert "bug #21841 [Console] Do not squash input changes made from console.command event (chalasr)" (chalasr)
This PR was merged into the 2.8 branch.
Discussion
----------
Revert "bug #21841 [Console] Do not squash input changes made from console.command event (chalasr)"
| Q | A
| ------------- | ---
| Branch? | 2.8
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #21953, https://github.com/symfony/symfony/issues/22050
| License | MIT
| Doc PR | n/a
A bit frustrated to revert this change since the BC break report lacks of information, making us unable to reproduce nor to look at improving the situation.
I'm going to re-propose this on master, covering the BC break that is identified, fixed and tested using the changes made in #21953. That will let the choice for the reporter to upgrade using the 1 required LOC.
Commits
-------
5af47c40dc
Revert "bug #21841 [Console] Do not squash input changes made from console.command event (chalasr)"
This commit is contained in:
commit
5f9d941365
@ -859,10 +859,6 @@ class Application
|
||||
// ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition
|
||||
}
|
||||
|
||||
// don't bind the input again as it would override any input argument/option set from the command event in
|
||||
// addition to being useless
|
||||
$command->setInputBound(true);
|
||||
|
||||
$event = new ConsoleCommandEvent($command, $input, $output);
|
||||
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
|
||||
|
||||
|
@ -42,7 +42,6 @@ class Command
|
||||
private $ignoreValidationErrors = false;
|
||||
private $applicationDefinitionMerged = false;
|
||||
private $applicationDefinitionMergedWithArgs = false;
|
||||
private $inputBound = false;
|
||||
private $code;
|
||||
private $synopsis = array();
|
||||
private $usages = array();
|
||||
@ -219,13 +218,11 @@ class Command
|
||||
$this->mergeApplicationDefinition();
|
||||
|
||||
// bind the input against the command specific arguments/options
|
||||
if (!$this->inputBound) {
|
||||
try {
|
||||
$input->bind($this->definition);
|
||||
} catch (ExceptionInterface $e) {
|
||||
if (!$this->ignoreValidationErrors) {
|
||||
throw $e;
|
||||
}
|
||||
try {
|
||||
$input->bind($this->definition);
|
||||
} catch (ExceptionInterface $e) {
|
||||
if (!$this->ignoreValidationErrors) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@ -681,14 +678,6 @@ class Command
|
||||
return $output->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function setInputBound($inputBound)
|
||||
{
|
||||
$this->inputBound = $inputBound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a command name.
|
||||
*
|
||||
|
@ -1117,31 +1117,6 @@ class ApplicationTest extends TestCase
|
||||
$this->assertEquals('some test value', $extraValue);
|
||||
}
|
||||
|
||||
public function testUpdateInputFromConsoleCommandEvent()
|
||||
{
|
||||
$dispatcher = $this->getDispatcher();
|
||||
$dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) {
|
||||
$event->getInput()->setOption('extra', 'overriden');
|
||||
});
|
||||
|
||||
$application = new Application();
|
||||
$application->setDispatcher($dispatcher);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$application
|
||||
->register('foo')
|
||||
->addOption('extra', null, InputOption::VALUE_REQUIRED)
|
||||
->setCode(function (InputInterface $input, OutputInterface $output) {
|
||||
$output->write('foo.');
|
||||
})
|
||||
;
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'foo', '--extra' => 'original'));
|
||||
|
||||
$this->assertEquals('overriden', $tester->getInput()->getOption('extra'));
|
||||
}
|
||||
|
||||
public function testTerminalDimensions()
|
||||
{
|
||||
$application = new Application();
|
||||
|
Reference in New Issue
Block a user