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
\yii\console\widgets\Table::widget problem with screenwidth #15552
Comments
Maybe having something similar on OSX with MAMP installed:
php -v
PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies |
Maybe also something which could be related: PHP Warning 'yii\base\ErrorException' with message 'str_repeat(): Second argument has to be greater than or equal to 0'
in /app/vendor/yiisoft/yii2/console/widgets/Table.php:289
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleError(2, 'str_repeat(): S...', '/app/vendor/yii...', 289, Array)
#1 /app/vendor/yiisoft/yii2/console/widgets/Table.php(289): str_repeat('\xE2\x95\x90', -2)
#2 /app/vendor/yiisoft/yii2/console/widgets/Table.php(181): yii\console\widgets\Table->renderSeparator('\xE2\x95\x94', '\xE2\x95\xA4', '\xE2\x95\x90', '\xE2\x95\x97')
#3 /app/vendor/luyadev/luya-core/console/commands/ImportController.php(218): yii\console\widgets\Table->run() |
Sounds like it... |
It happens randomly, therefore i thought its good to post for someone to debug, maybe it helps. |
Another exception:
@samdark would you accept a PR which checks if $size (https://github.com/yiisoft/yii2/blob/master/framework/console/widgets/Table.php#L356) is empty in order to prevent the exception and just use a default height like public $fallbackHeight = 25;
public function getFallbackHeight($size)
{
if ($size <= 2) {
return $this->fallbackHeight;
}
return $size;
} Something simliar for $rowSize (https://github.com/yiisoft/yii2/blob/master/framework/console/widgets/Table.php#L289). When running commands in dockerized environments this problem appears quite often. |
Yes. |
@machour This one could also be moved to 2.0.17 IMHO |
Agree. Moved. |
Should be fixed by 3b87c5f |
What steps will reproduce the problem?
use console widget table when screen size can't be determined
What is the expected result?
What do you get instead?
Additional info
yii2\console\widgets\Table.php::getScreenWidth() doesn't assign $this->_screenWidth when Console::getScreenSize() return false.
for you'r information on my system :
stty -a 2>&1
produce :
so when yii2\console\widgets\Table.php: calculateRowsSize() do :
it give a negative value for $screenWidth and produce the php error.
Proposed fix
Set a default value for screenWidth:
Will produce :
Only Fix the php error
will produce :
ugly but no error
The text was updated successfully, but these errors were encountered: