douxu0550 2019-05-16 02:48
浏览 105

如何在启用Xdebug时修复curl_exec调用挂起

I have a local ddev (docker based) PHP Drupal 7 development environment set up. I have set up Behat tests for this site utilizing the Behat Drupal Extension.

All of the Behat context files and the associated composer vendor folder lives outside of the site's web root in a testing folder. The folder structure looks something like:

  • Project

    • testing

    • public_html

I have xdebug enabled and using PhpStorm. I have set up a PhpStorm debug server and provided correct path mappings.

Debugging php code via a browser works great, debugging CLI commands works great. My issue occurs when I try to debug all code while running Behat tests via the CLI.

In the PhpStorm PHP Server configuration if I only set the path mappings for the testing folder I can debug any code within the testing folder and there are no curl issues. I obviously can't debug code in the public_html folder because I have not set the path mappings. When I do set the path mappings for both the testing and public_html folders, I can debug all code but any behat step definition that includes a Mink curl_exec() call to the site's local url, hangs for anywhere from 3 to 10 minutes!

My goal...

To be able to debug all php code in the testing and public_html folders while running Behat tests without curl_exec() hanging.

What I have tried...

I have PhpStorm Debug Max Simultaneous Connections set to 10 and have tried 20.

Here are my xdebug remote config settings:

xdebug.remote_addr_header => no value => no value
xdebug.remote_autostart => On => On
xdebug.remote_connect_back => Off => Off
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => host.docker.internal => host.docker.internal
xdebug.remote_log => no value => no value
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000

All of the following have all resulted in curl hanging:

  • Set xdebug.remote_autostart=0 and started the Xdebug session by passing a XDEBUG_CONFIG=idekey=PHPSTORM environment variable in with my behat command AND
    • NOT passing any cookie or GET parameter with the curl call.
    • Passing the same idekey as a cookie and GET parameter with the curl call
    • Passing a different idekey as a cookie and GET parameter with the curl call

Any help is greatly appreciated!!

  • 写回答

1条回答 默认 最新

  • doukaizha5417 2019-05-17 18:49
    关注

    After following @LazyOne advice I looked at the Xdebug logs more closely and noticed the hanging was occurring after a successful xDebug connection was made. This lead me to two possible causes; some rouge breakpoint that was not getting registered in the PhpStorm Debug tool window or something on the site was delaying the response.

    So I did the following:

    1. Removed all PhpStorm Debug breakpoints in the application and restarted PhpStorm.
    2. Realized the Automatic Cron setting in Drupal 7 Configuration was set to run every 1 Day so switched it to Never. My thinking was possibly the execution of Drupal Cron was getting stuck and not completing so every HTTP request was hanging.

    It worked and now I wish I had tested each of these steps separately because I don't know which one exactly was the solution. I am leaning towards #1 because when I switched off debugging in PhpStorm the Behat test would execute with no delay. Either way, if you have a similar issue try both of the above.

    评论

报告相同问题?

悬赏问题

  • ¥15 flask项目,怎么使用AJAX传数据库数据到echarts图表的data里,实现异步加载数据。
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?