Edit report at http://bugs.php.net/bug.php?id=50813&edit=1
ID: 50813
Comment by: mjk at emmjaykay dot org
Reported by: marc dot bennewitz at giata dot de
Summary: __isset() not called for uninitialized array offsets
$obj->test[0]
Status: Verified
Type: Bug
Package: Scripting Engine problem
Operating System: *
PHP Version: 5.*, 6
Block user comment: N
Private report: N
New Comment:
In my change, if I comment out the __isset definition, I get
Fatal error: Couldn't find implementation for method MyClass::__isset in
Unknown on line 0
where as on the unchanged code, I get
Notice: Key "test" does not exist in /home/mjk/php-5.3.5.orig/e.php on
line 22
bool(false)
I'm not sure if that's correct or not.
Previous Comments:
------------------------------------------------------------------------
[2011-02-01 07:55:20] mjk at emmjaykay dot org
I'm not so sure this patch is kosher since it checks the return value's
lval from the call to zend_std_call_issetter(). I don't see it in other
code.
------------------------------------------------------------------------
[2010-01-21 12:03:48] marc dot bennewitz at giata dot de
Thats the same:
>php -v
PHP 5.3.3-dev (cli) (built: Jan 21 2010 12:52:05)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
>php test.php
PHP Notice: Key "test" does not exist in /tmp/test.php on line 14
Notice: Key "test" does not exist in /tmp/test.php on line 14
bool(false)
------------------------------------------------------------------------
[2010-01-21 09:59:53] [email protected]
Please try using this snapshot:
http://snaps.php.net/php5.3-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2010-01-21 09:10:17] marc dot bennewitz at giata dot de
Description:
------------
On testing if an array key is available on an overloaded object variable
it doesn't check __isset before calling __get to get the variable for
checking the array key.
Reproduce code:
---------------
class MyClass
{
public function __isset($varname)
{
echo 'isset' . PHP_EOL;
return false;
}
public function __get($varname)
{
trigger_error('Key "' . $varname . '" does not exist',
E_USER_NOTICE);
}
}
$obj = new MyClass();
var_dump( isset($obj->test[0]) );
Expected result:
----------------
isset
bool(false)
Actual result:
--------------
PHP Notice: Key "test" does not exist in /tmp/test.php on line 14
Notice: Key "test" does not exist in /tmp/test.php on line 14
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=50813&edit=1