如何修复 Drush 8 / PHP 7.2 警告“count(): Parameter must be an array...”

yup*_*guy 5 linux php ubuntu

我在 Ubuntu 16.04 上运行 LAMP。我安装了 drupal 7,并且通过 Composer 1.5.2 版安装了 drush 8.1.3。我相信php7.2 中存在导致Github 上讨论的错误的错误,但是即使我应用了推荐的修复程序,即将 pear/console_table 更新到此处指示的最新版本,问题仍然存在。我还按照超级用户的说明进行操作,以确保我也安装了最新版本的 pear(未安装 PHPunit)。而且,仅供参考,根据此处找到drush 安装文档,我也对我的.bashrc文件进行了适当的更改(如下)。

每当我运行时,drush status我都会收到以下错误:

count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
PHP executable         :  /usr/bin/php                                 
PHP configuration      :  /etc/php/7.2/cli/php.ini                     
PHP OS                 :  Linux                                        
Drush script           :  /home/webdevusr/vendor/drush/drush/drush.php 
Drush version          :  8.1.13                                       
Drush temp directory   :  /tmp                                         
Drush configuration    :                                               
Drush alias files      :   
Run Code Online (Sandbox Code Playgroud)

如果我执行 drush sql-connect

Unable to load class Drush\Sql\Sql                                  [error]
Drush\Sql\SqlException: Unable to find a matching SQL Class. Drush   [error]
cannot find your database connection details. in
/home/webdevusr/vendor/drush/drush/commands/sql/sql.drush.inc:541
Stack trace:
#0
/home/webdevusr/vendor/drush/drush/commands/sql/sql.drush.inc(221):
drush_sql_get_class()
#1 /home/webdevusr/vendor/drush/drush/includes/command.inc(422):
drush_sql_connect()
#2 /home/webdevusr/vendor/drush/drush/includes/command.inc(231):
_drush_invoke_hooks(Array, Array)
#3 /home/webdevusr/vendor/drush/drush/includes/command.inc(199):
drush_command()
#4
/home/webdevusr/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67):
drush_dispatch(Array)
#5 /home/webdevusr/vendor/drush/drush/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#6 /home/webdevusr/vendor/drush/drush/drush.php(12): drush_main()
#7 {main}
Run Code Online (Sandbox Code Playgroud)

我的~/.bashrc文件内容如下:

export PATH="$HOME/.composer/vendor/bin:$PATH"

export PATH=/bin:/usr/local/bin:/usr/local/mysql/bin:$PATH

# Include Drush bash customizations.
if [ -f "/home/webdevusr/.drush/drush.bashrc" ] ; then
source /home/webdevusr/.drush/drush.bashrc
fi

# Include Drush completion.

if [ -f "/home/webdevusr/.drush/drush.complete.sh" ] ; then
source /home/webdevusr/.drush/drush.complete.sh
fi

# Include Drush prompt customizations.

if [ -f "/home/webdevusr/.drush/drush.prompt.sh" ] ; then
source /home/webdevusr/.drush/drush.prompt.sh
fi
Run Code Online (Sandbox Code Playgroud)

drush cc all从我的 drupal 安装文件夹中执行的结果是:

No Drupal site found, only 'drush' cache was cleared. 
Run Code Online (Sandbox Code Playgroud)

有人知道如何让 drush 为我的本地 (LAMP) Drupal 7 安装工作吗?

小智 1

您可以编辑 .config/composer/vendor/pear/console_table/Table.php 或首先在系统中查找该文件。使用您最喜欢的编辑器在第 789 行编辑中打开它。像这样将其静音:

@$this->_max_cols = max($this->_max_cols, count($rowdata));

你可以走了。