Bug #75868 [NEW]: is_resource() gettype() get_resources() inconsistent result on closed resource

From: Date: Wed, 24 Jan 2018 14:31:45 +0000
Subject: Bug #75868 [NEW]: is_resource() gettype() get_resources() inconsistent result on closed resource
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213688@lists.php.net to get a copy of this message
From:             bobonov at gmail dot com
Operating system: Ubuntu 17.10
PHP version:      7.2.1
Package:          Variables related
Bug Type:         Bug
Bug description:is_resource() gettype() get_resources() inconsistent result on closed resource

Description:
------------
Checking the closed resource with:
gettype() return resource (closed)
get_resources() list it as resource
is_resource() return false.

There is an ancient Bug #42797 (php 4.3.6) that is relevant to this bug

Test script:
---------------
<?php
$a = fopen('http://www.google.com',
'r');
echo "$a : the type is " . gettype($a)."\n";  // resource
var_dump(is_resource($a)); // true
print_r(get_resources());

fclose($a);
echo "$a : the type is " . gettype($a)."\n";  // resource closed
var_dump(is_resource($a)); // false
print_r(get_resources());


Expected result:
----------------
I expect is_resource() to return true since  get_resources() and
gettype() see the var as resource

Actual result:
--------------
Resource id #6 : the type is resource
bool(true)
Array
(
    [1] => Resource id #1
    [2] => Resource id #2
    [3] => Resource id #3
    [4] => Resource id #4
    [6] => Resource id #6
)
Resource id #6 : the type is resource (closed)
bool(false)
Array
(
    [1] => Resource id #1
    [2] => Resource id #2
    [3] => Resource id #3
    [4] => Resource id #4
    [6] => Resource id #6
)


-- 
Edit bug report at https://bugs.php.net/bug.php?id=75868&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=75868&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=75868&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=75868&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=75868&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=75868&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=75868&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=75868&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=75868&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=75868&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=75868&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=75868&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=75868&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=75868&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75868&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=75868&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=75868&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=75868&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75868&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=75868&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=75868&r=mysqlcfg



Thread (7 messages)

« previous php.bugs (#213688) next »