Bug #80342 [Nab]: is_resource returns false
| From: | cmb@php.net | Date: | Mon, 09 Nov 2020 13:20:45 +0000 |
| Subject: | Bug #80342 [Nab]: is_resource returns false | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230226@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80342&edit=1
ID: 80342
Updated by: cmb@php.net
Reported by: info at backups dot nl
Summary: is_resource returns false
Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: ubuntu server
PHP Version: 8.0.0RC3
Block user comment: N
Private report: N
New Comment:
Instead of
if ( !is_resource( $image ) )
use
if ( $image === false )
for compatibility with "all" PHP versions.
Previous Comments:
------------------------------------------------------------------------
[2020-11-09 12:55:18] jhdxr@php.net
This is intended. In php 8.0 a lot of resource has been converted into objects. see https://github.com/php/php-tasks/issues/6, and
https://github.com/php/php-src/pull/4714 for
your case.
------------------------------------------------------------------------
[2020-11-09 12:48:43] info at backups dot nl
Description:
------------
I am using the code below. in php 8.0 is_resource returns false on this code.
I can rewrite that code of course but i want to understand why it now suddenly does not work
anymore.
Is this a bug or is this caused by the changes made in php 8.0?
Please advice
Thank you !
Test script:
---------------
$file= '/var/public/wp-content/uploads/2020/11/image_001.jpg';
$image = imagecreatefromstring( file_get_contents( $file ) );
if ( !is_resource( $image ) )
return new WP_Error( 'error_loading_image', $image, $file );
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80342&edit=1