bug #15771 [Console] Ensure the console output is only detected as decorated when both stderr and stdout support colors (Seldaek)

This PR was merged into the 2.3 branch.

Discussion
----------

[Console] Ensure the console output is only detected as decorated when both stderr and stdout support colors

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #10592 #13449
| License       | MIT
| Doc PR        |

This is a simplified version of #13661 which does not create any issues with having two decorators but merely ensures that if either STDERR **or** STDOUT has colors disabled, then both will have decoration disabled. It's not a perfect solution but it's better than having both enabled as this breaks things. And I don't think we can come to a better solution without api changes.

Commits
-------

f3d8444 [Console] Ensure the console output is only detected as decorated when both stderr and stdout support colors
This commit is contained in:
Fabien Potencier 2015-09-13 13:30:23 +02:00
commit e2156d7c2c
1 changed files with 5 additions and 0 deletions

View File

@ -48,7 +48,12 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
{
parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
$actualDecorated = $this->isDecorated();
$this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
if (null === $decorated) {
$this->setDecorated($actualDecorated && $this->stderr->isDecorated());
}
}
/**