#43698 [NEW]: Assignment to inaccessible private property in __set() has no effect.

From: Date: Fri, 28 Dec 2007 16:20:49 +0000
Subject: #43698 [NEW]: Assignment to inaccessible private property in __set() has no effect.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120912@lists.php.net to get a copy of this message
From: robin_fernandes at uk dot ibm dot com Operating system: Windows PHP version: 5.3CVS-2007-12-28 (snap) PHP Bug Type: Scripting Engine problem Bug description: Assignment to inaccessible private property in __set() has no effect. Description: ------------ The assignment in the __set() method below is caught by the setter recursion guard. Subsequently, I would expect it to be treated like a direct assignment, and therefore to fail due to an attempt to write to another class's private property. Instead, nothing happens at all. I believe this is related to bug 38461, whereby a crash caused by a similar testcase was fixed, but the expected result of the assignment was not discussed. Reproduce code: --------------- <?php class C { function __set($name, $value) { echo "In " . __METHOD__ . "('$name', '$value')\n"; $this->$name = $value; } } class D extends C { private $hidden = "Original Value"; } $d = new D; $d->hidden = "New Value"; var_dump($d); ?> Expected result: ---------------- In C::__set('hidden', 'New Value') Fatal error: Cannot access private property D::$hidden in %s on line 5 Actual result: -------------- In C::__set('hidden', 'New Value') object(D)#1 (1) { ["hidden":"D":private]=> string(14) "Original Value" } -- Edit bug report at http://bugs.php.net/?id=43698&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43698&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43698&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43698&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43698&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43698&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43698&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43698&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43698&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43698&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43698&r=support Expected behavior: http://bugs.php.net/fix.php?id=43698&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43698&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43698&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43698&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43698&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43698&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43698&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43698&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43698&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43698&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43698&r=mysqlcfg

« previous php.bugs (#120912) next »