使用ReflectionException进行Drush失败:类Drush \ Sql \ Sql7没有构造函数

时间:2015-07-24 06:27:39

标签: drupal drupal-7 centos6 drush

我已按照http://docs.drush.org/en/master/install/的说明安装Drush(尝试了全局和个人选项)。

当我cd到Drupal站点root并键入" drush status"我得到以下内容:

 Drupal version         :  7.34
 Site URI               :  http://default
 PHP executable         :  /usr/bin/php
 PHP configuration      :  /etc/php.ini
 PHP OS                 :  Linux
 Drush script           :  /root/.composer/vendor/drush/drush/drush.php
 Drush version          :  7.0.0
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /var/www/site_dev
 Site path              :  sites/default

当我输入" drush cc all"我明白了:

No Drupal site found, only 'drush' cache was cleared.
'all' cache was cleared.    

当我输入" drush sqlc"我明白了:

exception 'ReflectionException' with message 'Class Drush\Sql\Sql7 does not have a constructor, so you cannot pass any constructor      [error]
arguments' in /root/.composer/vendor/drush/drush/includes/drush.inc:113
Stack trace:
#0 /root/.composer/vendor/drush/drush/includes/drush.inc(113): ReflectionClass->newInstanceArgs(Array)
#1 /root/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(605): drush_get_class('Drush\Sql\Sql', Array, Array)
#2 /root/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(588): drush_sql_get_version()
#3 /root/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(454): drush_sql_get_class()
#4 [internal function]: drush_sql_cli()
#5 /root/.composer/vendor/drush/drush/includes/command.inc(368): call_user_func_array('drush_sql_cli', Array)
#6 /root/.composer/vendor/drush/drush/includes/command.inc(219): _drush_invoke_hooks(Array, Array)
#7 [internal function]: drush_command()
#8 /root/.composer/vendor/drush/drush/includes/command.inc(187): call_user_func_array('drush_command', Array)
#9 /root/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(62): drush_dispatch(Array)
#10 /root/.composer/vendor/drush/drush/drush.php(70): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#11 /root/.composer/vendor/drush/drush/drush.php(11): drush_main()
#12 {main}

这让我觉得这个问题与MySQL有关(因为状态并没有列出数据库参数),但我无法弄明白。在网站下只有默认文件夹,因此它不是多站点安装。

有人可以告诉我们有什么不对吗?

更新 我已将PHP升级到5.5.27并重新安装了Drush 7.0.0。 根据建议here我从主文件夹中删除了my.cnf,之后" drush sqlc"开始工作,但是当我键入" drush -v -d status"它给了我:

Starting Drush preflight. [0.01 sec, 2.08 MB]                                                                                           [preflight]
Cache HIT cid: 7.0.0-commandfiles-0-81cc86c1995ab7206f383ec28ad43baf [0.01 sec, 2.14 MB]                                                    [debug]
Bootstrap to phase 0. [0.07 sec, 6.08 MB]                                                                                               [bootstrap]
Drush bootstrap phase : bootstrap_drupal_root() [0.08 sec, 6.43 MB]                                                                     [bootstrap]
Initialized Drupal 7.34 root directory at /var/www/site_dev [0.08 sec, 6.43 MB]                                                           [notice]
Find command files for phase 1 (max=7) [0.08 sec, 4.48 MB]                                                                                  [debug]
Cache HIT cid: 7.0.0-commandfiles-1-a0882f4af91e1d6b72794cc62bb1b558 [0.08 sec, 4.49 MB]                                                    [debug]
Drush bootstrap phase : bootstrap_drupal_site() [0.08 sec, 4.49 MB]                                                                     [bootstrap]
Initialized Drupal site default at sites/default [0.08 sec, 4.5 MB]                                                                        [notice]
Find command files for phase 2 (max=7) [0.09 sec, 4.5 MB]                                                                                   [debug]
Cache HIT cid: 7.0.0-commandfiles-2-f17fc6bdab2f74278df75194ca483893 [0.09 sec, 4.5 MB]                                                     [debug]
Drush bootstrap phase : bootstrap_drupal_configuration() [0.09 sec, 4.5 MB]                                                             [bootstrap]
Find command files for phase 3 (max=7) [0.09 sec, 4.51 MB]                                                                                  [debug]
sql-query: SELECT 1; [0.09 sec, 4.62 MB]                                                                                                [status]
Executing: mysql --defaults-extra-file=/tmp/drush_CKiVHd --database=site_dev --host=localhost --silent  < /tmp/drush_DG1fIs
  1
Drush bootstrap phase : bootstrap_drupal_database() [0.1 sec, 4.62 MB]                                                                  [bootstrap]
Successfully connected to the Drupal database. [0.11 sec, 5.13 MB]                                                                      [bootstrap]
Find command files for phase 4 (max=7) [0.11 sec, 5.13 MB]                                                                                  [debug]
Drush bootstrap phase : bootstrap_drupal_full() [0.11 sec, 5.13 MB]                                                                     [bootstrap]
Cannot modify header information - headers already sent by (output started at /root/.composer/vendor/drush/drush/includes/output.inc:38)[warning]
common.inc:698 [0.96 sec, 31.9 МБ]
Drush command terminated abnormally due to an unrecoverable error.

3 个答案:

答案 0 :(得分:3)

听起来可能是这个问题:7.x does not work with PHP 5.3.3

提供了in this comment的解决方案:

  

基类SqlVersion类没有构造函数而且还有   空数组传递给它的后代(Sql6Sql7)。

     

要解决此问题,请执行以下行:

     

return $reflectionClass->newInstanceArgs($constructor_args);

     

应替换为:

return !empty($constructor_args) ?
$reflectionClass->newInstanceArgs($constructor_args) :
$reflectionClass->newInstanceArgs();

或者,您可以升级PHP v5.4或更高版本。

或者,您可以将Drush降级为6.x。

答案 1 :(得分:0)

如果您在本地(开发)环境中运行此网站(很难从问题中得知......)

然后尝试将Drupal的settings.php文件中的数据库主机从“localhost”更改为“127.0.0.1”。

答案 2 :(得分:0)

如果您正在使用Windows,则需要验证是否正确设置了MYSQL的PATH变量。我升级了WAMP时遇到了问题。

这样的示例:C:\wamp\bin\mysql\mysql5.6.17\bin