php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31436 isset incorrectly returning true when passed a bad type
Submitted: 2005-01-07 02:09 UTC Modified: 2005-01-10 15:26 UTC
From: joshdf at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2004-01-10 OS: *
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: joshdf at gmail dot com
New email:
PHP Version: OS:

 

 [2005-01-07 02:09 UTC] joshdf at gmail dot com
Description:
------------
isset may return true to a $string->member being passed in.  Clearly, a string can not have a member variable; therefore, isset is expected to always return false in this case.  The actual result of the reproduced code for us is incorrect when using php 5.0.3, while the expected correct result is produced in php 5.0.0.

Reproduce code:
---------------
<?php
class Car
{
	var $mpg;
}
$car = new Car();
$car->mpg = 30;

//the normal case, should work
if( isset($car->mpg) )
	echo "mpg is set...this is normal<br>";

//the case that may not work right:
$some_random_string = "this is some random string, it has no mpg member";
if( isset($some_random_string->mpg) )
	echo "ERROR: This line should never be displayed<br>";
?>

Expected result:
----------------
mpg is set...this is normal

Actual result:
--------------
mpg is set...this is normal
ERROR: This line should never be displayed

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-10 15:26 UTC] sniper@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #31098
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 03 13:01:32 2024 UTC