From:             csmoak at andrew dot cmu dot edu
Operating system: All
PHP version:      5.0.0RC3
PHP Bug Type:     Feature/Change Request
Bug description:  __get/__set should allow recursive calls

Description:
------------
__get() and __set() are currently blocked from being implicitly called for
a particular instance of an object when they are currently executing.
However, this can cause code to behave differently if it is called from
within __get()/__set() or if it is called without __get()/__set().

The following example uses good OOP methodology that tries to make use of
__get() and __set(), but is hindered by it, instead.

The problem lies in the use of the in_get and in_set member variables in
the zend_object strcut to provide a blanket block to calling __get or
__set recursively (when called implicitly). A possible solution would be
to only prevent code directly in the __get() and __set() method bodies
from implicitly calling __get() or __set(), but allowing it in any called
code.

Reproduce code:
---------------
http://www.andrew.cmu.edu/user/csmoak/getset.phps

Expected result:
----------------
correct behavior (without making use of __get/__set):<br>
before set : default<br>
after set  : propertyValue<br>
PropertyAccessClass Object
(
    [property:private] => propertyValue
    [defaultProperty:private] => default
    [changed:private] => 1
)
<br><br>

incorrect behavior (making use of __get/__set):<br>
before set : default<br>
after set  : propertyValue<br>
PropertyAccessClass Object
(
    [property:private] => propertyValue
    [defaultProperty:private] => default
    [changed:private] => 1
)

Actual result:
--------------
correct behavior (without making use of __get/__set):<br>
before set : default<br>
after set  : propertyValue<br>
PropertyAccessClass Object
(
    [property:private] => propertyValue
    [defaultProperty:private] => default
    [changed:private] => 1
)
<br><br>

incorrect behavior (making use of __get/__set):<br>
<br />
<b>Notice</b>:  Undefined property:  PropertyAccessClass::$PropertyChanged
in <b>C:\ftproot\pnet\test2.php</b> on line <b>22</b><br />
<br />
<b>Notice</b>:  Undefined property:  PropertyAccessClass::$DefaultProperty
in <b>C:\ftproot\pnet\test2.php</b> on line <b>33</b><br />
before set : <br>
after set  : propertyValue<br>
PropertyAccessClass Object
(
    [property:private] => propertyValue
    [defaultProperty:private] => default
    [changed:private] => 
    [PropertyChanged] => 1
)


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

Reply via email to