php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: info at backups dot nl
New email:
PHP Version: OS:

 

 [2020-11-09 12:48 UTC] 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 );


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-09 12:55 UTC] jhdxr@php.net
-Status: Open +Status: Not a bug
 [2020-11-09 12:55 UTC] 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 13:20 UTC] cmb@php.net
Instead of

    if ( !is_resource( $image ) )

use

    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-2025 The PHP Group
All rights reserved.
Last updated: Fri Mar 14 15:01:30 2025 UTC