-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Make use of stderr for non reliable output #20632
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
[FrameworkBundle] Make use of stderr for non reliable output #20632
Conversation
1eac2be
to
b7af8c5
Compare
Isn't there a lot more than those 4 commands? What about (I guess keeping this in #20586 would be less painful to update as you target master too for this bug fix 😅) |
b7af8c5
to
b2920e7
Compare
@ogizanagi I made the changes only where it makes sense in my opinion, which exclude commands where the output give no relevant information at all. I just applied it on the
Not that much, each one can be merged independently and, since the subject of #20586 was "Add getErrorIo AND use stderr in existing commands", I do think it should be done in two PRs :) |
b2920e7
to
2207831
Compare
Note that when exceptions are thrown (which is the case in lot of commands including lint ones), the output goes to stderr naturally. |
Oh, I could have did it here if you just said me.. but ok then |
I had to check relevant places myself so it was simpler to submit it 😅 |
@@ -88,7 +89,8 @@ protected function execute(InputInterface $input, OutputInterface $output) | |||
$io = new SymfonyStyle($input, $output); | |||
|
|||
if (null === $twig = $this->getTwigEnvironment()) { | |||
$io->error('The Twig environment needs to be set.'); | |||
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io; | |||
$errorIo->error('The Twig environment needs to be set.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd challenge this one in order to simply throw a \RuntimeException
instead. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I've reverted a similar change in my previous PR thinking it was the same, but actually it's another place: https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Command/DebugCommand.php#L90
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure 👍 but should it be done here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it slightly changes the output and is done mainly in the aim to output it to stderr more straightforwardly, I'd say yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Twig Bridge DebugCommand update is still missing here, even in case the suggestion about throwing an exception instead is not considered. ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both debug/lint commands have been updated :)
Having two places to discuss/review/merge about the same thing looks not simpler to me, as you wish. |
Apply the patch then and I'll close mine. |
Done 2af000a |
👍 |
8ddb044
to
6eaaf28
Compare
Updated for using |
@@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output) | |||
$io = new SymfonyStyle($input, $output); | |||
|
|||
if (null === $twig = $this->getTwigEnvironment()) { | |||
$io->error('The Twig environment needs to be set.'); | |||
$io->getErrorStyle()->error('The Twig environment needs to be set.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail when the bridge is used with older versions (before 3.3) of the Console component which is completely valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted
@@ -62,11 +62,12 @@ protected function configure() | |||
protected function execute(InputInterface $input, OutputInterface $output) | |||
{ | |||
$io = new SymfonyStyle($input, $output); | |||
$errorIo = $io->getErrorStyle(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xabbuh The framework now has a conflict for symfony/console: <3.3
so it should be fine
@@ -85,8 +85,9 @@ protected function configure() | |||
protected function execute(InputInterface $input, OutputInterface $output) | |||
{ | |||
$io = new SymfonyStyle($input, $output); | |||
$errorIo = $io->getErrorStyle(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the same also applies to the SecurityBundle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it work (and make sense) to add a conflict with older versions of the Console?
bebd602
to
b64fe2d
Compare
Build failure unrelated (see #21198) |
b64fe2d
to
462a6f5
Compare
Rebased, tests are green. This is ready |
1b327f5
to
201bb4a
Compare
201bb4a
to
7b262d8
Compare
ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thank you @chalasr. |
…output (chalasr, ogizanagi) This PR was merged into the 3.3-dev branch. Discussion ---------- [FrameworkBundle] Make use of stderr for non reliable output | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Built-in commands should make use of the proper outputs. As a feature on master, considering that people may actually rely on stdout and the fact commands have been changed a lot since 2.7, I think it's not worth doing this change on lower branches. Please see also #20586 which adds a `SymfonyStyle::getErrorStyle()` shortcut for easily switching to stderr. Commits ------- 7b262d8 [FrameworkBundle] Use getErrorStyle() when relevant 9a3a568 Use stderr for some other commands 1ee48bf [FrameworkBundle] Make use of stderr for non reliable output
Built-in commands should make use of the proper outputs.
As a feature on master, considering that people may actually rely on stdout and the fact commands have been changed a lot since 2.7, I think it's not worth doing this change on lower branches.
Please see also #20586 which adds a
SymfonyStyle::getErrorStyle()
shortcut for easily switching to stderr.