#34816 [NEW]: Inconsitent behavior in ArrayObject for multi-dimensional data
| From: | adove at booyahnetworks dot com | Date: | Mon, 10 Oct 2005 17:42:24 +0000 |
| Subject: | #34816 [NEW]: Inconsitent behavior in ArrayObject for multi-dimensional data | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-86357@lists.php.net to get a copy of this message | ||
From: adove at booyahnetworks dot com
Operating system: WinXP
PHP version: 5.1.0RC1
PHP Bug Type: SPL related
Bug description: Inconsitent behavior in ArrayObject for multi-dimensional data
Description:
------------
If you create an ArrayObject with mutli-dimensional array data, you can
access unique element paths fine but you can not change/add any
multi-dimensional paths due to the dreaded "Fatal error: Objects used as
arrays in post/pre increment/decrement must return values by reference"
error. Note this happens in BOTH 5.0.5 AND 5.1.0RC1.
IMHO, either the documentation for ArrayObject should clearly indicate
that it supports uni-dimenisional data get/set and ONLY get for
multi-dimensional. OR, the object walk the passed data and turn all arrays
into ArrayObject instances?
Reproduce code:
---------------
$a = array(
"test" => array(
"one" => "dunno",
"two" => array(
"peekabo" => "do you see me?",
"anyone" => array("there")
)
)
);
$oArray = new ArrayObject($a);
var_dump($oArray);
echo "\n\\test\\one == " . $oArray["test"]["one"] . "\n\n";
// NEITHER of the two below will work!
$oArray["test"]["one"] = "Yes I do!";
$oArray["test"]["yes"] = array(
"hello" => "Goodbye!"
);
var_dump($oArray);
Expected result:
----------------
object(ArrayObject)#1 (1) {
["test"]=>
array(2) {
["one"]=>
string(5) "dunno"
["two"]=>
array(2) {
["peekabo"]=>
string(14) "do you see me?"
["anyone"]=>
array(1) {
[0]=>
string(5) "there"
}
}
}
}
\test\one == dunno
object(ArrayObject)#1 (1) {
["test"]=>
array(2) {
["one"]=>
string(5) "Yes I do!"
["two"]=>
array(2) {
["peekabo"]=>
string(14) "do you see me?"
["anyone"]=>
array(1) {
[0]=>
string(5) "there"
}
}
["yes"]=>
array(1) {
["hello"]=>
string(8) "Goodbye!"
}
}
}
Actual result:
--------------
object(ArrayObject)#1 (1) {
["test"]=>
array(2) {
["one"]=>
string(5) "dunno"
["two"]=>
array(2) {
["peekabo"]=>
string(14) "do you see me?"
["anyone"]=>
array(1) {
[0]=>
string(5) "there"
}
}
}
}
\test\one == dunno
Fatal error: Objects used as arrays in post/pre increment/decrement must
return values by reference in array_obje_test.php on line 16
--
Edit bug report at http://bugs.php.net/?id=34816&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34816&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34816&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34816&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34816&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34816&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34816&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34816&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34816&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34816&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34816&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=34816&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=34816&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34816&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34816&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34816&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34816&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34816&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34816&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34816&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34816&r=mysqlcfg