#28016 [Asn]: is_resource() returns false for resources of type "Unknown"
| From: | php at ter dot dk | Date: | Fri, 16 Apr 2004 12:37:21 +0000 |
| Subject: | #28016 [Asn]: is_resource() returns false for resources of type "Unknown" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-58255@lists.php.net to get a copy of this message | ||
ID: 28016
User updated by: php at ter dot dk
Reported By: php at ter dot dk
Status: Assigned
Bug Type: Scripting Engine problem
Operating System: *
PHP Version: 4CVS, 5CVS (2004-04-16)
Assigned To: derick
New Comment:
But will it solve the problem in my situation? After all, I do have a
resource by hand, and would be pretty sad if other functions wouldn't
recognize it as a resource.
I do agree though that making gettype not return "resource" for a
closed resource (since is_resource() already does that). I just don't
like the idea that these functions might not recognize my resource at
all.
- Peter Brodersen
Previous Comments:
------------------------------------------------------------------------
[2004-04-16 03:15:17] derick@php.net
No, the fix was correct. Close() in this case destroyed the resource
data in the variable, so it's no longer a resource anymore. I think the
correct thing to do here is to make gettype() not show "resource"
either.
------------------------------------------------------------------------
[2004-04-15 22:35:54] sniper@php.net
Derick, IMO, the fix for bug #27822 was incorrect.
Resource is still a resource even if it's closed..
Or you need to unset the variable with any 'close'.. :)
------------------------------------------------------------------------
[2004-04-15 21:15:58] php at ter dot dk
Description:
------------
(version of PHP is 4.3.6, not 4.3.6RC3, but I wasn't able to select
that)
If a resource for some reason is of type "Unknown", is_resource()
returns false. Though, gettype() still returns "resource" as type, as
always.
This behaviour in is_resource() has changed between 4.3.5 and 4.3.6.
I'm guessing here, but the new behaviour could be related to changes
introduced to fix bug 27822 (which was fixed in between 4.3.5 and
4.3.6).
In my example I'm using php-imlib to gain an object of type "Unknown".
Even though it isn't an official extension, there still is some
inconsistency between gettype() returning "resource" and is_resource()
returning false. In other words, it's the inconsistency between
is_resource() and gettype() I see as the bug.
Example is also available at: http://stock.ter.dk/resource_error.php
Reproduce code:
---------------
$i = imlib_create_image(100,200);
var_dump($i);
var_dump(gettype($i));
var_dump(is_resource($i));
Expected result:
----------------
resource(2) of type (Unknown)
string(8) "resource"
bool(true)
Actual result:
--------------
resource(2) of type (Unknown)
string(8) "resource"
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28016&edit=1