Bug #55731 [NEW]: __get after __unset

From: Date: Tue, 20 Sep 2011 02:35:23 +0000
Subject: Bug #55731 [NEW]: __get after __unset
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-163695@lists.php.net to get a copy of this message
From: Operating system: windows xp PHP version: 5.3.8 Package: Unknown/Other Function Bug Type: Bug Bug description:__get after __unset Description: ------------ <?php class Example{ private $p1; private $p2; function __construct($a){ $this->p1=$a; } function __get($elmname){ echo "Call_get()!"; //In order to follow the method __get() return $this->$elmname; } function __isset($name){ return isset($this->$name); } function __unset($name){ unset($this->$name); } } $example=new Example("v1","v2"); echo $example->p1."<br/>"; var_dump(isset($example->p2));//p2 is uninitialized,the result is bool(false) echo $example->p2;//This time,__get is called by 1 time. unset($example->p1); var_dump(isset($example->p1));//Because of __unset,the result is bool(false) echo $example->p1;//Amazing!I call the __get just once,but it seems that the __get method has bean called two times! ?> Expected result: ---------------- Call_get()! v1 bool(false) Call_get()!bool(false) Call_get()! Actual result: -------------- Call_get()! v1 bool(false) Call_get()!bool(false) Call_get()!Call_get()! -- Edit bug report at https://bugs.php.net/bug.php?id=55731&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55731&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55731&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55731&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55731&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55731&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55731&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55731&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55731&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55731&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55731&r=support Expected behavior: https://bugs.php.net/fix.php?id=55731&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55731&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55731&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55731&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55731&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55731&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55731&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55731&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55731&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55731&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55731&r=mysqlcfg

« previous php.bugs (#163695) next »