-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] progress bar fix #19012
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
[Console] progress bar fix #19012
Conversation
85ee0c8
to
db12bb6
Compare
There is still 1 drawback here: as the ProgressBar uses its own Terminal instance, it will ignore any explicit overwrite done in the Application. |
do you want to merge this in 3.2 only or in older branches as a bugfix ? |
I'm aware of the drawback. I don't see how to fix this and TBH, I don't think it matters too much as playing with the dimensions should only be done when testing an app. Only for 3.2. |
Added some deprecations now. |
*/ | ||
protected function getTerminalWidth() | ||
{ | ||
$dimensions = $this->getTerminalDimensions(); | ||
|
||
return $dimensions[0]; |
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.
please add the deprecation warnings too
The new |
a095d0b
to
8d71aff
Compare
added the deprecations and simplified the code again by removing |
9773191
to
5afbdbb
Compare
/** | ||
* Sets the terminal height. | ||
* | ||
* @param int |
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.
missing param name, makign the phpdoc invalid
60a2d62
to
a38bb97
Compare
It could be useful to configure width+height with an env var, especially in tests. |
@nicolas-grekas Done. I've kept the config in .travis.yml |
LGTM, except a test failure |
$this->terminalDimensions = array($width, $height); | ||
@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Set the ANSICON env var instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED); | ||
|
||
putenv('ANSICON='.$width.'x'.$height); |
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 is a bad idea, as it will also impact the detection of color support on Windows
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.
We should support a different env var following the same format if we want to go this way (but keeping support for the ANSICON one for auto-detection)
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, this code is broken, as it does not invalidate the Terminal cache
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.
What about using COLUMNS and LINES? These are what bash uses (they are magic variables that can be overriden, try echo $COLUMNS
).
6e105a8
to
2eeb7bd
Compare
534d825
to
c92b2b4
Compare
Broken test on HHVM not related. |
👍 with this patch: --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php
@@ -28,6 +28,8 @@ class UserPasswordEncoderCommandTest extends WebTestCase
public function testEncodePasswordEmptySalt()
{
+ putenv('COLUMNS=120');
+
$this->passwordEncoderCommandTester->execute(array(
'command' => 'security:encode-password', |
@fabpot are you sure ? the failing test is related to line wrapping in commands. I think one of your Console test does not properly reset the env variables on teardown, and so it impacts subsequent tests. Non-hhvm builds are unaffected because they use a separate PHP process per component to run things in parallel |
@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Set the COLUMNS and LINES env vars instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED); | ||
|
||
putenv('COLUMNS='.$width); | ||
putenv('LINES='.$height); |
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 does not work in case the dimensions were already retrieved previously, because of the Terminal internal cache
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.
fixed
660b6e8
to
b233974
Compare
should be good now :) |
b233974
to
355ad6c
Compare
} | ||
} | ||
|
||
if (0 === self::$width) { |
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.
not sure this check works: when is this zero?
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.
that's old code, removed.
355ad6c
to
dba73e7
Compare
dba73e7
to
2f81247
Compare
Thank you @TomasVotruba. |
This PR was merged into the 3.2-dev branch. Discussion ---------- [Console] progress bar fix | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #13019 | License | MIT | Doc PR | - This is #16490 where I've simplified the code as much as possible and added a test for the bug we're trying to fix. The main change is the renaming of the `TerminalDimensionsProvider` to just `Terminal`. The new class can probably be useful to add more about the terminal. Commits ------- 2f81247 switched to use COLUMNS and LINES env vars to change terminal dimensions bf7a5c5 fixed logic a589635 deprecated some Console Application methods 8f206c8 fixed CS, simplified code b030c24 [Console] ProgressBar - adjust to the window width (static)
Thank you @fabpot for finishing! |
This PR was merged into the 4.0-dev branch. Discussion ---------- [Console] Remove deprecated features | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~~#18999 #19012~~ | License | MIT | Doc PR | n/a Commits ------- 4cde3b9 [Console] Remove deprecated features
This is #16490 where I've simplified the code as much as possible and added a test for the bug we're trying to fix.
The main change is the renaming of the
TerminalDimensionsProvider
to justTerminal
. The new class can probably be useful to add more about the terminal.