Skip to content
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

count(): Parameter must be an array or an object that implements Countable #3226

Closed
Chi-teck opened this issue Dec 9, 2017 · 19 comments
Closed
Labels

Comments

@Chi-teck
Copy link
Collaborator

@Chi-teck Chi-teck commented Dec 9, 2017

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

@Chi-teck Chi-teck added the drush8 label Dec 9, 2017
@anavarre

This comment has been minimized.

Copy link

@anavarre anavarre commented Dec 11, 2017

Confirmed with Drush 9 RC1.

@Chi-teck

This comment has been minimized.

Copy link
Collaborator Author

@Chi-teck Chi-teck commented Dec 11, 2017

@anavarre Are you sure? Drush 9 has no dependency on pear/console_table.

@anavarre

This comment has been minimized.

Copy link

@anavarre anavarre commented Dec 11, 2017

No, I'm not. It happened when installing either the Lightning or Reservoir distro, not with vanilla Drupal 8.5.x - I honestly didn't dig deeper yet.

@anavarre

This comment has been minimized.

Copy link

@anavarre anavarre commented Dec 12, 2017

BTW, is it on Drush to fix the issue? It seems to me it could be a core bug https://www.drupal.org/project/drupal/issues/2928846

@Chi-teck

This comment has been minimized.

Copy link
Collaborator Author

@Chi-teck Chi-teck commented Dec 12, 2017

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.

@Ayesh

This comment has been minimized.

Copy link

@Ayesh Ayesh commented Dec 18, 2017

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.

@weitzman

This comment has been minimized.

Copy link
Member

@weitzman weitzman commented Jan 5, 2018

If someone wants to make a PR for drush8, that would be appreciated. Seems like @silent operator is better than copying the lib.

@Ayesh

This comment has been minimized.

Copy link

@Ayesh Ayesh commented Jan 5, 2018

@weitzman - Please see #3292 with the @silent workaround. Some of the builds are failing for connectivity issues, but majority of them passed.

@gentleKun

This comment has been minimized.

Copy link

@gentleKun gentleKun commented Mar 9, 2018

Hello,I met the same error,do you fix it out?

@greg-1-anderson

This comment has been minimized.

Copy link
Member

@greg-1-anderson greg-1-anderson commented Mar 9, 2018

Is this fixed in pear/console_table 1.3.1 / Drush 8.1.16? Not sure what the resolution was, but that seemed to be my conclusion during light testing yesterday. Didn't see the message when running 8.1.16.

@Ayesh

This comment has been minimized.

Copy link

@Ayesh Ayesh commented Mar 9, 2018

@jameswilson

This comment has been minimized.

Copy link

@jameswilson jameswilson commented Apr 19, 2018

Can confirm that running pear install Console_Table fixed this issue for me, which updated to the latest version 1.3.1

@binarycpu

This comment has been minimized.

Copy link

@binarycpu binarycpu commented May 24, 2018

Using pear install Console_Table I was also updated to 1.3.1 but I unfortunately am still flooded with count() warnings. When installing drush 8 dev, I get version 8.0.2; where when installing drush 8 I get version 8.0.0. I think something is confused. Regardless, upgrading to drush 9 resolved all of the issues.

@darkdiesel

This comment has been minimized.

Copy link

@darkdiesel darkdiesel commented Apr 11, 2019

drush 7 and php7.2 the same problem

@Chi-teck

This comment has been minimized.

Copy link
Collaborator Author

@Chi-teck Chi-teck commented Apr 11, 2019

I think the PHP requirements in the documentation are not correct. Old Drush version are likely not compatible with PHP 7.2+.
https://docs.drush.org/en/master/install/#drupal-compatibility

fmiro added a commit to fmiro/docker-apache-drupal that referenced this issue Jun 6, 2019
Use Console_Table 1.3.1 instead of Console_Table 1.1.5 that comes by default with drush 6.7.0 version.
At https://github.com/drush-ops/drush/blob/6.x/includes/environment.inc Console_Table 1.1.5 is downloaded dynamically if it does not already exist in lib folder. So we download 1.3.1 first and rename it to 1.1.5 as a "trick" to make it work without any other change
pataquets added a commit to pataquets/docker-apache-drupal that referenced this issue Jun 12, 2019
@kenahoo

This comment has been minimized.

Copy link
Contributor

@kenahoo kenahoo commented Oct 1, 2019

I have Drush 7.4 and PHP 7.3.9, and I'm still seeing this issue. Console_Table is already upgraded to 1.3.1. What's the proper fix for this issue?

@Chi-teck

This comment has been minimized.

Copy link
Collaborator Author

@Chi-teck Chi-teck commented Oct 1, 2019

@kenahoo Drush 7 is unsupported. Updating to Drush 8 will resolve the issue.

@kenahoo

This comment has been minimized.

Copy link
Contributor

@kenahoo kenahoo commented Oct 2, 2019

Thanks @Chi-teck , that indeed resolved it.

@chriscalip

This comment has been minimized.

Copy link

@chriscalip chriscalip commented Oct 31, 2019

Error sighted. If drush is globally installed this can be fixed via:
composer global require pear/console_table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.