Edit report at https://bugs.php.net/bug.php?id=70315&edit=1
ID: 70315
Updated by: cmb@php.net
Reported by: patriciotarantino at gmail dot com
Summary: imagecreatefromstring() returns 500 Server Error but
page is fully rendered
Status: Closed
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:
> Isn't it a more general bug, at the architecture level, that an
> "unknown" error code can cause PHP to render pages in a
> half-broken state?
In my opinion, passing unknown error codes is a programmer error
(core or extension), and should be reported (and fixed) as bug on
a case-by-case basis (like this one).
Previous Comments:
------------------------------------------------------------------------
[2016-07-18 23:18:20] razzari at gmail dot com
I'm not familiar with PHP internals. Not at all.
But have to ask.
Feel free to ignore if it's a dumb question:
Isn't it a more general bug, at the architecture level, that an "unknown" error code
can cause PHP to render pages in a half-broken state?
Where "half-broken" is the worst kind: looks good to the naked eye, but rejects search
engine crawlers.
------------------------------------------------------------------------
[2016-07-18 22:59:51] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6cb75fb1e8208d79f58351340923059d0d077ee6
Log: Fix #70315: 500 Server Error but page is fully rendered
------------------------------------------------------------------------
[2016-07-07 12:55:59] cmb@php.net
Okay, I'am able to reproduce the reported behavior now. It happens
only when an external libgd is used, not with PHP's bundled libgd.
> PHP Unknown error: imagecreatefromstring(): gd-png: fatal [â¦]
> PHP Parse error: imagecreatefromstring(): gd-png error: [â¦]
That's the crux. The bundled libgd reports instead:
| Warning: imagecreatefromstring(): gd-png: fatal [â¦]
| Warning: imagecreatefromstring(): gd-png error: [â¦]
One culprit is php_gd_error_method()[1] which simply forwards to
php_verror() without adjusting the type argument, although libgd
uses other error codes than PHP (for instance, GD_ERROR is 3,
which is unknown to PHP). While a simple mapping of the error
codes would solve this problem, it still would cause different
behavior depending whether the bundled or an external libgd is
used. In this case the bundled libgd would raise warnings only and
simply go on, while an external libgd would raise errors and abort
the script.
As changing libgd obviously isn't an option due to the ABI break,
we probably should change PHP's bundled libgd (i.e. raise E_ERROR
instead of E_WARNING), but that would cause a BC break, so maybe
it's best to do that only for PHP 7.1.0, and to accept the
different behavior for older versions. php_gd_error_method(),
however, should be fixed for PHP 5.6+.
I'll prepare a PR.
[1] <https://github.com/php/php-src/blob/php-7.0.8/ext/gd/gd.c#L1021-L1025>
------------------------------------------------------------------------
[2016-07-04 14:17:37] razzari at gmail dot com
I can also repro with Nginx and FPM/FastCGI.
PHP Version 5.5.9-1ubuntu4.17.
GD Version 2.1.1-dev.
------------------------------------------------------------------------
[2016-07-04 13:32:59] razzari at gmail dot com
This was mod_php (libapache2-mod-php5.6).
------------------------------------------------------------------------
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