|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80342 is_resource returns false
Submitted: 2020-11-09 12:48 UTC Modified: 2020-11-09 13:47 UTC
From: info at backups dot nl Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 8.0.0RC3 OS: ubuntu server
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.
Block user comment
Status: Assign to:
Bug Type:
From: info at backups dot nl
New email:
PHP Version: OS:


 [2020-11-09 12:48 UTC] info at backups dot nl
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 );


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-09 12:55 UTC]
-Status: Open +Status: Not a bug
 [2020-11-09 12:55 UTC]
This is intended. In php 8.0 a lot of resource has been converted into objects. see, and for your case.
 [2020-11-09 13:20 UTC]
Instead of

    if ( !is_resource( $image ) )


    if ( $image === false )

for compatibility with "all" PHP versions.
 [2020-11-09 13:47 UTC] info at backups dot nl
Thank you for the explanation.  Please close the report
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Jul 06 15:03:42 2022 UTC