Bug #50813 [Com]: __isset() not called for uninitialized array offsets $obj->test[0]

From: Date: Tue, 01 Feb 2011 06:55:20 +0000
Subject: Bug #50813 [Com]: __isset() not called for uninitialized array offsets $obj->test[0]
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-158382@lists.php.net to get a copy of this message
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:

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.


Previous Comments:
------------------------------------------------------------------------
[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] jani@php.net

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


Thread (8 messages)

« previous php.bugs (#158382) next »