Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Infinite loop when fatal error in views
  • Hello, I was working on a small app when I encountered an infinite loop. After investigation, the infinite loop is started when I have a (fatal) error in my views instead of simply display the error details (message, stacktrace, etc.). I tried on a fresh install and with with the current version (zip downloaded this morning). If you want to reproduce the bug, it's pretty simple. On any install: Create a view with a fatal error like (two ")" after true): <?php if(true)) : ?>
    <h1>It works</h1>
    <?php endif; ?> Then just try to call this view in a controller: public function action_bug()
    {
    return Response::forge(View::forge('test'));
    } And enjoy the infinite loop. :D Am I the only one to have this behavior?
  • That code example produces this here (in development mode):
    Parsing Error!
    
    ErrorException [ Parsing Error ]: syntax error, unexpected ')'
    
    so I think you have other issues...
  • You're right. I dug a bit more and found that the issue is coming from a php settings. When "zlib.output_compression" is enabled, I have the infinite loop with a lot of notices like that: Notice! ErrorException [ Notice ]: ob_end_clean() [ref.outcontrol]: failed to delete buffer zlib output compression COREPATH/classes/error.php @ line 145: 144: {
    145: ob_end_clean();
    146: } As I see it, the exception process throw a new notice exception which throw a new notice exception and so on (here is the infinite loop). When I disable this setting I have the correct behavior (error message).
  • I have the same issue and I was never able to fix it. Have to try if for same reason!!
  • This can't be worked around. PHP does not allow you to fool with the output buffers in a shutdown callback when compression is enabled. You can disable compression, but that will just print all the notice errors that you now find in your logs. The only solution is to disable compression in development mode (which is they only mode that shows php errors). A possible workaround is to not enable zlib compression in your php.ini, but do it in code based on the environment:
    // enable zlib compression when in development mode
    \Fuel::$env == \Fuel::DEVELOPMENT or ini_set('zlib.output_compression', '1');
    
    You can do this in anything that is always loaded at every request.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion