php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79966 imagecreatetruecolor has Fatal error
Submitted: 2020-08-12 20:40 UTC Modified: 2020-08-13 07:34 UTC
From: dpfender44 at gmail dot com Assigned:
Status: Wont fix Package: GD related
PHP Version: 8.0.0beta1 OS: Windows 10 Pro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dpfender44 at gmail dot com
New email:
PHP Version: OS:

 

 [2020-08-12 20:40 UTC] dpfender44 at gmail dot com
Description:
------------
Both imagecreate() and imagecreatetruecolor() have the same fatal error where there is no problem with PHP 7.4.9.  This code has been working for years and I just recently tried PHP 8.0.0Beta1 and got this error.

<b>Fatal error</b>:  Uncaught Error: Object of class GdImage could not be converted to string

Test script:
---------------
$img = imagecreatetruecolor(800, 530);
$img = imagecreate(800, 530);


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-12 20:44 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2020-08-12 20:44 UTC] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2020-08-12 20:49 UTC] dpfender44 at gmail dot com
-Status: Feedback +Status: Open
 [2020-08-12 20:49 UTC] dpfender44 at gmail dot com
Test Script:
<?php
$img = imagecreatetruecolor(800, 530);
$img = imagecreate(800, 530);
?>
 [2020-08-12 20:51 UTC] dpfender44 at gmail dot com
-Summary: imagecreatetrucolor has Fatal error +Summary: imagecreatetruecolor has Fatal error
 [2020-08-12 20:51 UTC] dpfender44 at gmail dot com
Changed spelling in Summary
 [2020-08-12 21:18 UTC] danack@php.net
exactly which line are you saying gives that error?

I'm pretty sure you aren't including the actual line of code is giving that error in your bug report, and that the error lies elsewhere.
 [2020-08-12 21:19 UTC] danack@php.net
-Status: Open +Status: Feedback
 [2020-08-12 21:42 UTC] dpfender44 at gmail dot com
-Status: Feedback +Status: Open
 [2020-08-12 21:42 UTC] dpfender44 at gmail dot com
Sorry. Not a bug.  The debug statement following the create statements tried to convert the function result to string for printing.  When I disabled the debug output, then everything worked as it should.  With this new "feature" in PHP 8 that objects are not converted to strings, I need to check a lot of my existing code.  This situation may impact many users and it should be emphasized as a very incompatible change in this new PHP version.
 [2020-08-12 22:08 UTC] requinix@php.net
-Status: Open +Status: Wont fix
 [2020-08-12 22:08 UTC] requinix@php.net
This is why we ask for a "complete example script".

> With this new "feature" in PHP 8 that objects are not converted to strings,
PHP has never allowed objects to be converted to strings. Not unless they implemented __toString. Nothing about this has changed for PHP 8.
 [2020-08-13 07:07 UTC] cmb@php.net
These classes could support conversion to string for BC reasons.
 [2020-08-13 07:34 UTC] nikic@php.net
They could, but I don't think they should. Converting a resource to string doesn't make a lot of sense, and is only really useful for debugging code. I don't believe that using __toString() for debug representations is considered acceptable.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 13:01:29 2024 UTC