php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53931 read_property not invoked on write thru a nested object
Submitted: 2011-02-04 22:06 UTC Modified: 2013-02-18 00:34 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mark dot rhoads at rightnow dot com Assigned:
Status: No Feedback Package: Class/Object related
PHP Version: 5.3.5 OS: *nix
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-02-04 22:06 UTC] mark dot rhoads at rightnow dot com
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.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-05 03:39 UTC] cataphract@php.net
Can you give an example with which to reproduce this?

This really looks like a bug on your part, namely failing to adapt get_property_ptr_ptr. See http://wiki.php.net/internals/engine/objects#get_property_ptr_ptr
 [2011-02-05 03:40 UTC] cataphract@php.net
-Status: Open +Status: Feedback
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 10:01:28 2024 UTC