8000 bug #22027 Revert "bug #21841 [Console] Do not squash input changes m… · symfony/symfony@5f9d941 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5f9d941

Browse files
committed
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, #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 ------- 5af47c4 Revert "bug #21841 [Console] Do not squash input changes made from console.command event (chalasr)"
2 parents e1ab801 + 5af47c4 commit 5f9d941

File tree

3 files changed

+5
-45
lines changed

3 files changed

+5
-45
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -859,10 +859,6 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
859859
// ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition
860860
}
861861

862-
// don't bind the input again as it would override any input argument/option set from the command event in
863-
// addition to being useless
864-
$command->setInputBound(true);
865-
866862
$event = new ConsoleCommandEvent($command, $input, $output);
867863
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
868864

src/Symfony/Component/Console/Command/Command.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Command
4242
private $ignoreValidationErrors = false;
4343
private $applicationDefinitionMerged = false;
4444
private $applicationDefinitionMergedWithArgs = false;
45-
private $inputBound = false;
4645
private $code;
4746
private $synopsis = array();
4847
private $usages = array();
@@ -219,13 +218,11 @@ public function run(InputInterface $input, OutputInterface $output)
219218
$this->mergeApplicationDefinition();
220219

221220
// bind the input against the command specific arguments/options
222-
if (!$this->inputBound) {
223-
try {
224-
$input->bind($this->definition);
225-
} catch (ExceptionInterface $e) {
226-
if (!$this->ignoreValidationErrors) {
227-
throw $e;
228-
}
221+
try {
222+
$input->bind($this->definition);
223+
} catch (ExceptionInterface $e) {
224+
if (!$this->ignoreValidationErrors) {
225+
throw $e;
229226
}
230227
}
231228

@@ -681,14 +678,6 @@ public function asXml($asDom = false)
681678
return $output->fetch();
682679
}
683680

684-
/**
685-
* @internal
686-
*/
687-
public function setInputBound($inputBound)
688-
{
689-
$this->inputBound = $inputBound;
690-
}
691-
692681
/**
693682
* Validates a command name.
694683
*

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,31 +1117,6 @@ public function testRunWithDispatcherAddingInputOptions()
11171117
$this->assertEquals('some test value', $extraValue);
11181118
}
11191119

1120-
public function testUpdateInputFromConsoleCommandEvent()
1121-
{
1122-
$dispatcher = $this->getDispatcher();
1123-
$dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) {
1124-
$event->getInput()->setOption('extra', 'overriden');
1125-
});
1126-
1127-
$application = new Application();
1128-
$application->setDispatcher($dispatcher);
1129-
$application->setAutoExit(false);
1130-
1131-
$application
1132-
->register('foo')
1133-
->addOption('extra', null, InputOption::VALUE_REQUIRED)
1134-
->setCode(function (InputInterface $input, OutputInterface $output) {
1135-
$output->write('foo.');
1136-
})
1137-
;
1138-
1139-
$tester = new ApplicationTester($application);
1140-
$tester->run(array('command' => 'foo', '--extra' => 'original'));
1141-
1142-
$this->assertEquals('overriden', $tester->getInput()->getOption('extra'));
1143-
}
1144-
11451120
public function testTerminalDimensions()
11461121
{
11471122
$application = new Application();

0 commit comments

Comments
 (0)
0