-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Separate formatter for stdout/stderr #13661
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
Conversation
👍 |
for reference: 👎 see #13449 (comment) |
While I can understand the concern for non-BC in the case of not "clone-able" Formatters, I think the case of actually running into such a scenario is so highly unlikely that it's negligible. |
I agree with you that it's a remote scenario, but still is a BC since put more restriction on the constructor; also cloning a DI instance smells to me. So, I don't say this PR should not be merged, but probably is not a good idea to merge it in |
The fix looks good, but I would prefer if we added an extra |
@xabbuh one additional question then, should calls to |
…ter-per-stdout-stderr * '2.3' of github.com:symfony/symfony: (273 commits) #15331 add infos about deprecated classes to UPGRADE-3.0 [Security] removed useless else condition in SwitchUserListener class. [travis] Tests deps=low with PHP 5.6 [Console] Fix console output with closed stdout [Security] fix check for empty usernames [Form] updated exception message of ButtonBuilder::setRequestHandler() [travis] Fix deps=high jobs [HttpFoundation] [PSR-7] Allow to use resources as content body and to return resources from string content [DependencyInjection] Remove unused code in XmlFileLoader [HttpFoundation] Behaviour change in PHP7 for substr bumped Symfony version to 2.3.32 updated VERSION for 2.3.31 update CONTRIBUTORS for 2.3.31 updated CHANGELOG for 2.3.31 fixed some tests Remove excess whitespace Added 'default' color [HttpFoundation] Reload the session after regenerating its id [HttpFoundation] Add a test case to confirm a bug in session migration [Finder] Command::addAtIndex() fails with Command instance argument ...
@alcohol Maybe we should check in if both formatters are the same and only in this case change the stderr related stuff too. |
…corated 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
[Console]
When piping output from a console command through
| more
for example, stderr is still considered to have color support although stdout does not. When stdout and stderr share the same formatter, this results in color codes being output while this is not desired behaviour.E.g.
without patch
with patch
$ php stdout.php | more OK
The cleanest solution I could think of, was simply cloning the given formatter rather than sharing the same instance.
Partial credit goes to @Seldaek as well for discovering and debugging this unexpected behaviour with me.