欢迎各位兄弟 发布技术文章
这里的技术是共享的
今天在使用Drush时突然发现无法使用了,提示错误:
Drush command terminated abnormally due to an unrecoverable error. [error]
经测试,不是Drush配置问题,也不是Drupal内核的问题,在于我写的一个模块hook_init() 函数是跳转引起的,导致Drush进入死循环。
查看Drush Debug信息:
$ drush -v -d status
Bootstrap to phase 0. [0 sec, 1.86 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.01 sec, 1.98 MB] [bootstrap]
Loading drushrc [bootstrap]
"/Applications/rubystack/apps/drupal/drush/drushrc.php" into "drush"
scope. [0.01 sec, 1.98 MB]
Cache MISS cid: 6.0-commandfiles-0-b85971c7841e4094247c123114aed123 [debug]
[0.01 sec, 1.99 MB]
Cache SET cid: 6.0-commandfiles-0-b85971c7841e4094247c123114aed123 [debug]
[0.01 sec, 2.01 MB]
Bootstrap to phase 0. [0.05 sec, 5.34 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.07 sec, [bootstrap]
5.35 MB]
Initialized Drupal 7.26 root directory at [notice]
/Applications/rubystack/apps/drupal/htdocs [0.08 sec, 6.21
MB] www.111cn.net
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.08 sec, [bootstrap]
6.22 MB]
Initialized Drupal site default at sites/default [0.08 sec, 6.22 MB] [notice]
Cache MISS cid: 6.0-install_profile-66ecfeb9791a023150773849f1550c5d [debug]
[0.08 sec, 6.22 MB]
Cache MISS cid: 6.0-commandfiles-2-90b5571ff64221f80c3320ec33b2ed28 [debug]
[0.08 sec, 6.22 MB]
Cache SET cid: 6.0-commandfiles-2-90b5571ff64221f80c3320ec33b2ed28 [debug]
[0.09 sec, 6.23 MB]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.09[bootstrap]
sec, 6.24 MB]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [0.1 sec, [bootstrap]
7.86 MB]
Successfully connected to the Drupal database. [0.1 sec, 7.86 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [0.1 sec, 7.86[bootstrap]
MB]
Drush command terminated abnormally due to an unrecoverable error. [error]
[0.19 sec, 21.9 MB]根据以上Debug,判断Drush没有问题,是Drupal中的hook引起的。
解决方法
如果你也遇到此种情况,请检查一下你的自定义模块中的一个钩子,如:
hook_init
hook_boot
Drush 是通过PHP CLI命令行模式运行的,CLI的PHP配置环境和 Apache等使用的PHP.ini 有所差别。如果访问网站没问题,通过CLI访问有问题的话,说明你写的钩子代码存在问题。
来自 http://www.111cn.net/sys/linux/58961.htm