From: tomas_matousek at hotmail dot com
Operating system: WinXP
PHP version: 5.1.1
PHP Bug Type: Scripting Engine problem
Bug description: Recursive call to setter "blocks" the property
Description:
------------
In the following example, the __setter invoked by $x->a = "g1"; statement
tries to write to "a" property again by $this->a = "a"; statement in the
switch. This latter access is correctly considered to be recursive and
thus treated as assignment to $this->a and not as a recursive call. That's
ok. However, after returning from the __setter and when invoking it again
by $x->b = "g2"; the $this->a = "b"; should call the __setter because we
it is not a recursive call ("b" was accessed, not "a"). Hence $this->a =
"b"; should invoke __setter in this case. And that doesn't happen.
Reproduce code:
---------------
class C
{
function __set($f,$v)
{
echo "set('$f','$v')\n";
switch ($f)
{
case "a": $this->a = "a"; break;
case "b": $this->a = "b"; break;
}
}
}
$x = new C;
$x->a = "g1"; // this blocks "a" on $x forever
$x->b = "g2";
Expected result:
----------------
set('a','g1')
set('b','g2')
set('a','b')
Actual result:
--------------
set('a','g1')
set('b','g2')
--
Edit bug report at http://bugs.php.net/?id=35651&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=35651&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=35651&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=35651&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=35651&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=35651&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35651&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35651&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35651&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35651&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35651&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=35651&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=35651&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35651&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35651&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35651&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35651&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35651&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35651&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35651&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35651&r=mysqlcfg