Edit report at https://bugs.php.net/bug.php?id=70315&edit=1
ID: 70315
Comment by: razzari at gmail dot com
Reported by: patriciotarantino at gmail dot com
Summary: imagecreatefromstring() returns 500 Server Error but
page full renderized
Status: Feedback
Type: Bug
Package: GD related
Operating System: Ubuntu
PHP Version: 5.6.12
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This is still happening on PHP Version 5.6.23.
Screenshot: https://i.imgur.com/p680DMk.png
Note that BOTH the test text AND the 500 status code are displayed.
As noted by the OP, this only happens if display_errors is off.
If I enable errors, things work as expected. The error is displayed, and the page returns with a 200
OK status. Screenshot: https://i.imgur.com/8jyuiot.png
Compare this with standard platform behavior, where an error with display_errors off will produce a
500 error AND a blank page. It is NOT displaying the test text. Screenshot https://i.imgur.com/VCBOmun.png and sample code:
<?php
# This works as expected.
ini_set("display_errors", 0);
trigger_error("Some error.", E_USER_ERROR);
echo "This should not render";
?>
So to recap, expected behavior is:
Display errors OFF: Blank page, 500 status code.
Display errors ON: Visible error text, some page content that worked, and 200 status code.
Actual result in this situation is:
Display errors OFF: Some page content that worked, 500 status code.
Why this is a serious issue: site owners and visitors will believe the site is working OK. But
Google will believe it's utterly broken and won't bother crawling it.
Previous Comments:
------------------------------------------------------------------------
[2016-07-03 05:20:03] pajoye@php.net
Cmb cannot reproduce it.
Also I do not see the 500 header.
Doyou have either logs or backtrace if the 500 is due to something else?
In any case it is definitely not GD as everything goes aa expected from a gd point of view.
------------------------------------------------------------------------
[2016-07-03 04:22:20] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
------------------------------------------------------------------------
[2016-06-27 19:22:24] razzari at gmail dot com
@cmb can repro in PHP version 5.5.35.
@pajoye it's OK if the echo happens. The problem is that the page also includes an HTTP Error
500 header. Which is hugely wrong.
------------------------------------------------------------------------
[2016-06-22 07:19:55] pajoye@php.net
The header itself does not control the code execution.
The imagecreatefromstring returns false on error. That means the echo will happen.
It is the caller job to check the value and act accordingly. In case you expect the echo to never
happen on error, that's not the case using this piece of code.
------------------------------------------------------------------------
[2016-06-21 21:32:49] cmb@php.net
> If you use imagecreatefromstring() with an invalid string, it
> returns a 500 Internal Server Error in the HTTP headers, [â¦]
Indeed, that is not supposed to happen, and I can't reproduce it,
actually. Please double-check with any of the recent PHP versions
(5.5.36, 5.6.22, 7.0.7).
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=70315
--
Edit this bug report at https://bugs.php.net/bug.php?id=70315&edit=1