添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

This only happens on PHP 7.2

$ php drush.php st
count(): Parameter must be an array or an object that implements Countable   [warning]
Table.php:789
count(): Parameter must be an array or an object that implements Countable   [warning]
Table.php:789
count(): Parameter must be an array or an object that implements Countable   [warning]
Table.php:789
count(): Parameter must be an array or an object that implements Countable   [warning]
Table.php:789
count(): Parameter must be an array or an object that implements Countable   [warning]
Table.php:789
count(): Parameter must be an array or an object that implements Countable   [warning]
Table.php:789
count(): Parameter must be an array or an object that implements Countable   [warning]
Table.php:789
 PHP configuration      :  /etc/php/7.2/cli/php.ini 
 PHP OS                 :  Linux                    
 Drush script           :  /var/www/drush/drush.php 
 Drush version          :  8.1.16-dev               
 Drush temp directory   :  /tmp                     
 Drush configuration    :                           
 Drush alias files      :                             

pear/Console_Table#14

It is a general PHP 7.2 issue. count() function should not be used to count uncountable values anymore.
http://php.net/manual/en/migration72.incompatible.php#migration72.incompatible.warn-on-non-countable-types.

This particular warning comes from Pear Console Table package. I referenced related issue in the ticket description. That package does not seem actively maintained. Given it is just a single class, we could simply copy it to Drush 8 codebase.

A backtrace says the call is in includes/output.inc:303, and it doesn't look like we can fix/workaround this from Drush's side.

function _updateRowsCols($rowdata = null) {
   // ...
  $this->_max_cols = max($this->_max_cols, count($rowdata));
  // ...

Console_Table class is doing it wrong because it relies on the count() to function as an !empty() as well.
My 👍 to copy, fix, and keep the class ourselves. It's not like we can make significant changes (for example use a better library) at this 8.x age.

Alternately we could @silent() the parent caller. Feels dirty either way.