ID: 38640 Updated by: [EMAIL PROTECTED] Reported By: ruslan dot kyrychuk at gmail dot com -Status: Assigned +Status: Closed Bug Type: Scripting Engine problem Operating System: Windows 2003, XP PHP Version: 5.1.5 Assigned To: helly New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Looks like I committed the patch and forgot to close report. Anyway, it works fine now. Previous Comments: ------------------------------------------------------------------------ [2006-08-29 11:08:23] [EMAIL PROTECTED] Assigned to the maintainer. Marcus, please take a look at this patch: http://tony2001.phpclub.net/dev/tmp/bug38640.diff I don't want to commit it when you're still on vacation, since I don't understand what was the original idea behind getValue/setValue - it seems quite obvious that they must use getter/setter, but for some reason they don't. The patch changes both of them to use appropriate engine calls. ------------------------------------------------------------------------ [2006-08-29 10:02:11] ruslan dot kyrychuk at gmail dot com Description: ------------ When unsetting object property it unsetted from object then __get method of object is called while accessing it. Besides property exists in all reflection objects (ReflectionObject and ReflectionProperty) but cause Fatal error while getting it. Reproduce code: --------------- <?php class B{} class A { public $Var = null; public function __construct() { $this->Var= new B(); } public function __get($name) { echo "get {$name}\n"; if(isset($this->Var)) { return $this->Var; } else { echo "Undefined variable\n"; return null; } } public function __unset($nm) { echo "unset"; } } $a = new A(); unset($a->Var); $o = new ReflectionObject($a); $p = $o->getProperty('Var'); Reflection::export($o);//Variable Exists Reflection::export($p);//Variable Exists var_dump($a->Var);//__get called var_dump($p->getValue($a)); //Fatal error ?> Expected result: ---------------- $o = new ReflectionObject($a); has correct current instance properties or $p->getValue($a) - will call __get method too and not cause fatal error. Actual result: -------------- Object of class [ <user> class A ] { @@ D:\WWW\www.usoftinc.com\test2.php 3-27 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ <default> public $Var ] } - Dynamic properties [0] { } - Methods [3] { Method [ <user, ctor> public method __construct ] { @@ D:\WWW\www.usoftinc.com\test2.php 6 - 9 } Method [ <user> public method __get ] { @@ D:\WWW\www.usoftinc.com\test2.php 10 - 22 - Parameters [1] { Parameter #0 [ <required> $name ] } } Method [ <user> public method __unset ] { @@ D:\WWW\www.usoftinc.com\test2.php 23 - 26 - Parameters [1] { Parameter #0 [ <required> $nm ] } } } } Property [ <default> public $Var ] get Var Undefined variable NULL <br /> <b>Fatal error</b>: Internal error: Could not find the property Var in <b>test2.php</b> on line <b>36</b><br /> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38640&edit=1