Bug #53931 [NEW]: read_property not invoked on write thru a nested object
| From: | mark dot rhoads at rightnow dot com | Date: | Fri, 04 Feb 2011 21:06:12 +0000 |
| Subject: | Bug #53931 [NEW]: read_property not invoked on write thru a nested object | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-158498@lists.php.net to get a copy of this message | ||
From:
Operating system: *nix
PHP version: 5.3.5
Package: Class/Object related
Bug Type: Bug
Bug description:read_property not invoked on write thru a nested object
Description:
------------
I have a custom object implementation with its own read_property and
write_property handlers where some properties are also objects.
Attemptying to write a property within the nested object when the nested
object has not been previously accessed via read_property will cause a
stdClass object to be invented and assigned to the property instead of
calling read_property to get the underlying object.
If the the first access is a write to a property of a nested object, then
read_property is not called for the nested object and a stdClass object is
invented and assigned:
$obj->nestedObject->someProperty = someValue;
assert( 'stdClass' == get_class( $obj->nestedObject ) );
However, if the first access is a read then it all works fine:
$someValue = $obj->nestedObject->someProperty; // read_property is called
for nestedObject
$obj->nestedObject->someProperty = someValue; // and now the write works
First performing any kind of read access allows this to work just fine.
E.g. this works
$obj->nestedObject;
$obj->nestedObject->someProperty = someValue;
Or this:
$avalue = $obj->nestedObject->someProperty; // calls read_property on
nestedObject
$obj->nestedObject->someProperty = someValue;
The problem only occurs when the very first access is a write to a
properpty of the nested property.
--
Edit bug report at http://bugs.php.net/bug.php?id=53931&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53931&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53931&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53931&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53931&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53931&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53931&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53931&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53931&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53931&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53931&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53931&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53931&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53931&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53931&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53931&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53931&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53931&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53931&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53931&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53931&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53931&r=mysqlcfg