Hi,
I've just got notification about https://bugs.php.net/bug.php?id=50921
(because I was commenting on the past). I've checked why do we not set http
500, and found this: http://lxr.php.net/xref/PHP_5_4/main/main.c#1154
it was added with
http://git.php.net/?p=php-src.git;a=commit;h=8039433291bd4fa36c897e93047d1ebd538dadbb
for fixing https://bugs.php.net/bug.php?id=42722
I'm a little bit confused how is that change fixing the originaly reported
problem (fatal errors doesn't show up in the output even though that
display_errors is enabled and error_reporting is set to E_ALL).
I don't think that the current behavior is correct, could somebody tell me
what did I missed?
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
We can't set 500 response code if HTTP headers were already sent.
We also don't set 500 response code if display_error is "on", because
browsers won't show the actual page with error message (may be it was just
IE6 or below and it's not a problem anymore).
Thanks. Dmitry.
Hi,
I've just got notification about https://bugs.php.net/bug.php?id=50921
(because I was commenting on the past). I've checked why do we not set http
500, and found this: http://lxr.php.net/xref/PHP_5_4/main/main.c#1154
it was added with
http://git.php.net/?p=php-src.git;a=commit;h=8039433291bd4fa36c897e93047d1ebd538dadbb
for fixing https://bugs.php.net/bug.php?id=42722
I'm a little bit confused how is that change fixing the originaly reported
problem (fatal errors doesn't show up in the output even though that
display_errors is enabled and error_reporting is set to E_ALL).
I don't think that the current behavior is correct, could somebody tell me
what did I missed?--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
We also don't set 500 response code if display_error is "on", because
browsers won't show the actual page with error message (may be it was just
IE6 or below and it's not a problem anymore).
I don't believe this is the case with any browser we might still be
reasonably expected to support. The browser generic error pages are
only displayed when there is no body content or a content-type it
doesn't understand.
If people are worried that this element, another ini setting could
always be introduced to control the behaviour separately from
display_errors.
Chris Wright wrote (on 25/06/2014):
I don't believe this is the case with any browser we might still be
reasonably expected to support. The browser generic error pages are
only displayed when there is no body content or a content-type it
doesn't understand.
Internet Explorer's "friendly error messages" are shown in preference to
any content smaller than a certain number of bytes (I can't remember the
exact threshold, but you will find plenty of minimal error pages padded
out with garbage comments as a workaround).
I've just had a quick look around online, and can't see anything saying
that this "feature" was removed in more recent versions. In fact, I just
did a quick test in IE11, and a page returning HTTP 500 and containing
the text "Done." is indeed replaced with the default error page. :(
Regards,
Rowan Collins
[IMSoP]
On Wed, Jun 25, 2014 at 4:32 PM, Rowan Collins rowan.collins@gmail.com
wrote:
Chris Wright wrote (on 25/06/2014):
I don't believe this is the case with any browser we might still be
reasonably expected to support. The browser generic error pages are
only displayed when there is no body content or a content-type it
doesn't understand.Internet Explorer's "friendly error messages" are shown in preference to
any content smaller than a certain number of bytes (I can't remember the
exact threshold, but you will find plenty of minimal error pages padded out
with garbage comments as a workaround).I've just had a quick look around online, and can't see anything saying
that this "feature" was removed in more recent versions. In fact, I just
did a quick test in IE11, and a page returning HTTP 500 and containing the
text "Done." is indeed replaced with the default error page. :(
we can't(and shouldn't) try to pad the response, as it could be any format,
not just html.
but I do think that we could expect the developer to be able to use the
view source functionallity to see the "true" output when presented with the
generic IE error page.
and this feature of ours breaks the semantic meaning of the http response
code and causes problems for those using any other browser than IE.
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
Chris Wright wrote (on 25/06/2014):
I don't believe this is the case with any browser we might still be
reasonably expected to support. The browser generic error pages are
only displayed when there is no body content or a content-type it
doesn't understand.Internet Explorer's "friendly error messages" are shown in preference to any
content smaller than a certain number of bytes (I can't remember the exact
threshold, but you will find plenty of minimal error pages padded out with
garbage comments as a workaround).I've just had a quick look around online, and can't see anything saying that
this "feature" was removed in more recent versions. In fact, I just did a
quick test in IE11, and a page returning HTTP 500 and containing the text
"Done." is indeed replaced with the default error page. :(
I tested briefly on my machine before sending the previous mail, but
it looks like I have the option set as outlined in the KB article
Ferenc linked - sorry for the misinformation.
Given this apparent variation/unpredictability, having another ini
setting to control the behaviour is possibly not a bad idea?
We can't set 500 response code if HTTP headers were already sent.
we have the !SG(headers_sent) check for that, and I'm not proposing to
remove that(albeit I think that we could handle the special scenario, when
the only output is generated by the error, but that is a separate topic).
We also don't set 500 response code if display_error is "on", because
browsers won't show the actual page with error message (may be it was just
IE6 or below and it's not a problem anymore).
I see. I assume this is related to http://support.microsoft.com/kb/294807
where by default IE shows pretty but generic message for non-2xx messages
if the response content length is less than or equal to a specific
threshold(512 bytes for 500 errors for example).
I don't think that it was a good idea to patch our error handling for the
sake of an usability feature only present in one browser.
thanks for the explanation!
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
I see. I assume this is related to http://support.microsoft.com/kb/294807
where by default IE shows pretty but generic message for non-2xx messages
if the response content length is less than or equal to a specific
threshold(512 bytes for 500 errors for example).
I don't think that it was a good idea to patch our error handling for the
sake of an usability feature only present in one browser.
Don’t other browsers do this as well? I believe Chrome and Firefox do, at least for 404 errors.
--
Andrea Faulds
http://ajf.me/
I see. I assume this is related to
http://support.microsoft.com/kb/294807
where by default IE shows pretty but generic message for non-2xx messages
if the response content length is less than or equal to a specific
threshold(512 bytes for 500 errors for example).
I don't think that it was a good idea to patch our error handling for the
sake of an usability feature only present in one browser.Don’t other browsers do this as well? I believe Chrome and Firefox do, at
least for 404 errors.
I could only check chrome, safari and firefox on my mac, but all of those
properly show the expected output(123) for
<?php
header('HTTP/1.1 500 Internal Server Error');
echo "123";
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
We can't set 500 response code if HTTP headers were already sent.
we have the !SG(headers_sent) check for that, and I'm not proposing to
remove that(albeit I think that we could handle the special scenario,
when
the only output is generated by the error, but that is a separate
topic).
I believe this causes some inconsistency, sometimes status code is
changed, sometimes not. Uncertain which is worse - wrong code or harder
to predict behavior.
johannes
On Wed, Jun 25, 2014 at 5:25 PM, Johannes Schlüter johannes@schlueters.de
wrote:
We can't set 500 response code if HTTP headers were already sent.
we have the !SG(headers_sent) check for that, and I'm not proposing to
remove that(albeit I think that we could handle the special scenario,
when
the only output is generated by the error, but that is a separate
topic).I believe this causes some inconsistency, sometimes status code is
changed, sometimes not. Uncertain which is worse - wrong code or harder
to predict behavior.
you mean it would be inconsistent if we would signal the error with a http
500 when it is technically possible (we haven't sent out the headers)
versus when the error happened after the headers were already sent?
if we consider this as inconsistency, we are already inconsistent, and I'm
not sure what would be the consistent alternative: not sending http 500 at
all?
but as I mentioned I'm not really interested changing the headers already
sent scenario (as there isn't much we could do), but I do think that the
current behavior about only setting the response code to 500
if display_errors is disabled is questionable.
I would like to know if you think that changing this is out of the question
or not, and if we would change it, should it happen a minor or a major
version.
I also think it would make sense to document the current behavior, I
couldn't find anything regarding this in the docs.
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu