doupang5433 2016-08-19 21:58
浏览 40
已采纳

nginx fastcgi返回允许的内存大小耗尽而不是未找到异常

I have a website, written in Symfony2. when users want to access a route which doesn't exists, PHP returns

FastCGI sent in stderr:
PHP message:PHP Fatal error: Allowed memory size of xxx bytes exhausted (tried to allocate 85 bytes)
symfony/symfony/src/Symfony/Component/Debug/Exception/FlattenException. php on line 296

which is in flattenArgs function: (i think it gets in loop but i don'y know why)

elseif (is_array($value)) {
  if ($level > 10) {
    $result[$key] = array('array', '*DEEP NESTED ARRAY*');
  } else {
    $result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count));
  }
} 

I have increased the memory_limit value in my php.ini, and also checked my configs. The other sites with same config written in pure PHP are working safe and write.

But naturally it should return 404, not found exception.

  • 写回答

1条回答 默认 最新

  • duanhuang1967 2017-04-10 06:48
    关注

    so i found the solution! you shouldn't use security context in error twigs. in my case i was using is_granted in header, processing some kind of errors is before defining security context.

    you can pass it by first checking user object and then security context.

    for example {%if app.user and is_granted('IS_AUTHENTICATED_FULLY')%}

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?