#48489 [NEW]: Modifying an array member of an ArrayObject doesn't pass through offsetGet/Set
| From: | angafenion at yahoo dot com | Date: | Sun, 07 Jun 2009 08:40:53 +0000 |
| Subject: | #48489 [NEW]: Modifying an array member of an ArrayObject doesn't pass through offsetGet/Set | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-138073@lists.php.net to get a copy of this message | ||
From: angafenion at yahoo dot com
Operating system: win32
PHP version: 5.3.0RC2
PHP Bug Type: SPL related
Bug description: Modifying an array member of an ArrayObject doesn't pass through
offsetGet/Set
Description:
------------
I overrode the methods of ArrayObject to normalize the keys before setting
and getting members. It appears that the overridden methods are skipped
when modifying an array member.
Reproduce code:
---------------
<?php
class foo extends ArrayObject
{
public function __construct($data = array(),
$flags = self::ARRAY_AS_PROPS,
$iterator = "ArrayIterator")
{
parent::__construct($data, $flags, $iterator);
}
public function offsetSet($key, $val)
{
echo "offsetSet invoked\n";
parent::offsetSet($key, $val);
}
public function offsetGet($key)
{
echo "offsetGet invoked\n";
return parent::offsetGet($key);
}
}
$foo = new foo();
$foo->baz = array();
echo count($foo->baz) . "\n";
echo "---\n";
$foo->baz['bar'] = 'foo';
echo count($foo->baz) . "\n";
Expected result:
----------------
offsetSet invoked
offsetGet invoked
0
---
offsetGet invoked --[*]
offsetSet invoked _/
offsetGet invoked
1
[*] actually, I'm not sure exactly what output to expect here, but at
least one of these I think should appear
Actual result:
--------------
offsetSet invoked
offsetGet invoked
0
---
offsetGet invoked
1
--
Edit bug report at http://bugs.php.net/?id=48489&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48489&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48489&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48489&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=48489&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48489&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=48489&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=48489&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=48489&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=48489&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=48489&r=support
Expected behavior: http://bugs.php.net/fix.php?id=48489&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=48489&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=48489&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=48489&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48489&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48489&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=48489&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=48489&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=48489&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=48489&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=48489&r=mysqlcfg