将Symfony从2.1升级到2.2后,我遇到了问题。 当一次运行所有功能测试时(注意在运行单个测试时没有发生这种情况,无论哪个),我得到一个错误,无限循环停留在
PHP Fatal error: Maximum function nesting level of '150' reached, aborting! in project_path\vendor\symfony\symfony\src\Symfony\Component\ClassLoader\DebugClassLoader.php on line 81
部分追踪:
...
14. Symfony\Component\BrowserKit\Client->submit() project_path\other_path\Tests\Controller\LoginControllerTest.php:53
15. Symfony\Component\BrowserKit\Client->request() project_path\vendor\symfony\symfony\src\Symfony\Component\BrowserKit\Client.php:224
16. Symfony\Bundle\FrameworkBundle\Client->doRequest() project_path\vendor\symfony\symfony\src\Symfony\Component\BrowserKit\Client.php:264
17. Symfony\Component\HttpKernel\Client->doRequest() project_path\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Client.php:111
18. Symfony\Component\HttpKernel\Kernel->handle() project_path\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Client.php:61
19. Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle() project_path\app\bootstrap.php.cache:411
20. Symfony\Component\HttpKernel\HttpKernel->handle() project_path\app\bootstrap.php.cache:1101
21. Symfony\Component\HttpKernel\HttpKernel->handleRaw() project_path\app\bootstrap.php.cache:975
22. Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher->dispatch() project_path\app\bootstrap.php.cache:990
23. Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() project_path\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher.php:135
24. Symfony\Component\EventDispatcher\EventDispatcher->dispatch() project_path\vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher.php:167
25. Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() project_path\vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\EventDispatcher.php:53
26. call_user_func() project_path\vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\EventDispatcher.php:164
27. Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher->Symfony\Component\HttpKernel\Debug\{closure}() project_path\vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\EventDispatcher.php:164
28. call_user_func() project_path\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher.php:447
29. Symfony\Component\Security\Http\Firewall->onKernelRequest() project_path\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher.php:447
30. Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener->handle() project_path\vendor\symfony\symfony\src\Symfony\Component\Security\Http\Firewall.php:66
31. Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener->onSuccess() project_path\vendor\symfony\symfony\src\Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener.php:143
32. Symfony\Component\ClassLoader\DebugClassLoader->loadClass() project_path\vendor\symfony\symfony\src\Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener.php:0
33. Symfony\Component\ClassLoader\DebugClassLoader->findFile() project_path\vendor\symfony\symfony\src\Symfony\Component\ClassLoader\DebugClassLoader.php:95
...
在升级之前,所有测试工作正常,现在使用时会抛出该错误:
$form = $crawler->selectButton('Login')->form();
$form['_password'] = '123ASDasd';
$form['_username'] = 'MattKing';
$crawler = $client->submit($form); //this is LoginControllerTest.php:53 from error above
或
$link = $crawler->selectLink('Matt King')->link();
$client->click($link); // --> error
或
$client = static::createClient();
$client->followRedirects(true);
$crawler = $client->request('GET', '/login'); // --> error
另一个问题是使用默认的symfony翻译功能。切换用户的语言环境后 - 测试抛出与上面相同的错误。当我注释掉切换区域设置时,则发生其他错误(如上所述)。请注意,它可能是由上述相同的问题引起的。
我搜索了几天的理由并放弃了。知道如何解决这个问题吗?
答案 0 :(得分:2)
我有同样的问题。我通过将其添加到我的php.ini来解决这个问题:
xdebug.max_nesting_level = 200
XDebug不应该在生产服务器上运行,因此不应该抛出错误。
(见this issue)