From:             tomas_matousek at hotmail dot com
Operating system: WinXP
PHP version:      5.0.4
PHP Bug Type:     Zend Engine 2 problem
Bug description:  ArrayAccess doesn't work at all

Description:
------------
I looks like you have never do in-depth testing with ArrayAccess. I you
did you must realize many things are wrong there. It took me less then 5
minutes to kill PHP several times using this naively implemented feature.




Reproduce code:
---------------
class ArrayClass implements ArrayAccess {

public $a = array();

function offsetExists($index) {

    return array_key_exists($index, $this->a);

}

function offsetGet($index) {

    return $this->a[$index];

}

function offsetSet($index, $newval) {

    return $this->a[$index] = $newval;

}

function offsetUnset($index) {

    unset($this->a[$index]);

}

}



Expected result:
----------------
It's unclear for me what should I expect.
Definitly not the crashes.

Can anyone explain, what should I expect from e.g.
$obj[1][2][3] = 1; ?

And what should 
$a =& $obj[1][2][3];
do?


Actual result:
--------------
$obj[array()] = 1; // crash
$obj[][] = 1;      // crash
$x =& $obj[1]      // crash
$obj[$obj[1]] = 1; // if offsetGet() returns null, the offsetSet() is
called then
$obj[1]++; // doesn't work at all even if both offsetGet and offsetSet are
modified to return by reference

-- 
Edit bug report at http://bugs.php.net/?id=33169&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33169&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33169&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33169&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33169&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33169&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33169&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33169&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33169&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33169&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33169&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33169&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33169&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33169&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33169&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33169&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33169&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33169&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33169&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33169&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33169&r=mysqlcfg

Reply via email to