From: ruslan dot kyrychuk at gmail dot com
Operating system: Windows 2003, XP
PHP version: 5.1.5
PHP Bug Type: Scripting Engine problem
Bug description: Fatal error while get unsetted property.
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 bug report at http://bugs.php.net/?id=38640&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=38640&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=38640&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=38640&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38640&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=38640&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38640&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38640&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38640&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38640&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38640&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=38640&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=38640&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38640&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38640&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38640&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38640&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38640&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38640&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38640&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38640&r=mysqlcfg