bug #20328 [Console] Fix empty COLUMNS/LINES env vars (nicolas-grekas)
This PR was merged into the 3.2-dev branch.
Discussion
----------
[Console] Fix empty COLUMNS/LINES env vars
| Q | A
| ------------- | ---
| Branch? | 3.2
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Here is a python app that fails otherwise:
test.py:
```python
import os
int(os.environ.get('COLUMNS', 80))
```
test.php:
```php
<?php
putenv('COLUMNS=');
passthru('python test.py');
```
result:
```
$ php test.php
Traceback (most recent call last):
File "test.py", line 3, in <module>
int(os.environ.get('COLUMNS', 80))
ValueError: invalid literal for int() with base 10: ''
```
Commits
-------
8ad991e
[Console] Fix empty COLUMNS/LINES env vars
This commit is contained in:
commit
b0e94f19aa
@ -31,7 +31,7 @@ class Terminal
|
||||
self::initDimensions();
|
||||
}
|
||||
|
||||
return self::$width;
|
||||
return self::$width ?: 80;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,7 +49,7 @@ class Terminal
|
||||
self::initDimensions();
|
||||
}
|
||||
|
||||
return self::$height;
|
||||
return self::$height ?: 50;
|
||||
}
|
||||
|
||||
private static function initDimensions()
|
||||
|
Reference in New Issue
Block a user