No 500 header on notice exception under PHP 5.4

Notice: This thread is very old.
crempa
Member | 198
+
0
-

Hi Nette debugger (tracy now?) don't send 500 as response code in case of catching notice exception under PHP 5.4. It works under 5.3. This is Nette or PHP bug or feature?

tested on PHP 5.4.10 and last dev Nette (2.1)

Last edited by crempa (2013-04-10 11:07)

crempa
Member | 198
+
0
-

OK problem is more complex, all exceptions throwed in template after something is sent to output are catched by Tracy but response code is not changed.

sample:

<?php
//preseneter
$t = new FileTemplate('template.phtml');
$t->render();
?>

template.phtml:

some output
<?php throw new Exception ?>
another content

code 200 returned under PHP 5.4

AaAAb
Member | 6
+
0
-

use ob_start, headers are already sent…

enumag
Member | 2118
+
0
-

Pretty sure that it's the same in PHP 5.3 as well. Simply if there already is a output, headers can't be changed anymore – not a bug.

crempa
Member | 198
+
0
-

Thanks for response, the problem was in output_buffering parameter in php.ini
I have disabled it under php 5.4 config.

enumag
Member | 2118
+
0
-

If you enable it to solve this you should keep in mind that it actually slows down your application. With OB enabled PHP has to wait until the whole HTML is generated before sending anything to the browser. With OB disabled (which I think is default) output is sent right away and the browser can begin its processing few miliseconds earlier.

AaAAb
Member | 6
+
0
-

Is it necessary to throw an exception in rendering? Don't worry about component, components are rendering with output buffering. Throwing exceptions in presenter template cause unable to show some user-friendly error message or do a fallback.