ID: 44807 User updated by: agostone at freemail dot hu Reported By: agostone at freemail dot hu -Status: Feedback +Status: Open Bug Type: Scripting Engine problem Operating System: Windows Xp PHP Version: 5.2.5 New Comment:
I've deleted my php installation, kept only php.ini. downloaded and installed php from this location it: http://snaps.php.net/win32/php5.2-win32-latest.zip Executed the code, here are the results: Calling: setRaw() Class: A| Passed Value:shouldn't be prefixed Class: B| Passed Value:shouldn't be prefixed Class: A| Passed Value:(prefixed) shouldn't be prefixed Calling: __set() Class: B| Passed Value:should be prefixed Class: A| Passed Value:(prefixed) should be prefixed Variable after setraw: (prefixed) shouldn't be prefixed Variable after set: (prefixed) should be prefixed Seems it still exists. Previous Comments: ------------------------------------------------------------------------ [2008-04-24 11:09:48] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows (zip): http://snaps.php.net/win32/php5.2-win32-latest.zip For Windows (installer): http://snaps.php.net/win32/php5.2-win32-installer-latest.msi ------------------------------------------------------------------------ [2008-04-23 14:09:33] agostone at freemail dot hu Description: ------------ If i have an overloaded __set function in a class and call parent::__set from another function, the parent calls the child's __set back and a loop gets created like this: parent::__set (initial call) child::_set parent::_set I need __set function to do some prefixing by default when assigning new string properties by default, i need a custom function to assign un-prefixed properties too, if there is a need (will happen very rarely)... I need this to auto prefix string variables passed to my view object (they gotta be passed as object properties), the MVC framework is a 3rd party framework, i'm extending it's view object and i don't want to modify the original source... Reproduce code: --------------- <?php class A { public function __set($pKey, $pValue) { echo("Class: ".get_class()."| Passed Value:".$pValue."<BR>"); $this->$pKey = $pValue; return true; } } class B extends A { function setRaw($pKey, $pValue) { parent::__set($pKey, $pValue); } function __set($pKey, $pValue) { echo("Class: ".get_class()."| Passed Value:".$pValue."<BR>"); $pValue = $this->prefix($pValue); parent::__set($pKey, $pValue); } function prefix($pValue) { if(is_string($pValue)) { return "(prefixed) ".$pValue; } return $pValue; } } $b = new B(); echo("Calling: setRaw()<br>"); $b->setRaw("raw", "shouldn't be prefixed"); echo("<br>"); echo("Calling: __set()<br>"); $b->prefixed = "should be prefixed"; echo("<br>Variable after setraw: ".$b->raw); echo("<br>Variable after set: ".$b->prefixed); echo("<br>"); ?> Expected result: ---------------- Calling: setRaw() Class: A| Passed Value:shouldn't be prefixed Calling: __set() Class: B| Passed Value:should be prefixed Class: A| Passed Value:(prefixed) should be prefixed Variable after setRaw: shouldn't be prefixed Variable after set: (prefixed) should be prefixed Actual result: -------------- Calling: setRaw() Class: A| Passed Value:shouldn't be prefixed Class: B| Passed Value:shouldn't be prefixed Class: A| Passed Value:(prefixed) shouldn't be prefixed Calling: __set() Class: B| Passed Value:should be prefixed Class: A| Passed Value:(prefixed) should be prefixed Variable after setraw: (prefixed) shouldn't be prefixed Variable after set: (prefixed) should be prefixed ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44807&edit=1