#26794 [Com]: $that not available in parent class
ID: 26794 Comment by: davidc at blesys dot com Reported By: alex_boyer at hotmail dot com Status: Verified Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS-2004-01-11 New Comment: Sorry, I don't understand. Is $that a new feature of PHP5? Previous Comments: [2004-01-05 09:20:05] alex_boyer at hotmail dot com i mean that $that is not available in parent class A (but IT IS available in class B) [2004-01-05 09:17:14] alex_boyer at hotmail dot com Description: $that is not available in parent class B (uncomment code in class A you will see it). So it is not possible to clone class in a recursive way. Reproduce code: --- class A { public $a; function __clone(){ //if( $that === null ) die('$that is null'); $this-a = $that-a; } } class B extends A { public $b; function __clone(){ parent::__clone(); $this-b = $that-b; } } $b = new B(); $b-a = 'AAA'; $b-b = 'BBB'; $clone = $b-__clone(); print_r($clone); Expected result: B Object ( [b] = BBB [a] = AAA ) Actual result: -- B Object ( [b] = BBB [a] = ) -- Edit this bug report at http://bugs.php.net/?id=26794edit=1
#26794 [Com]: $that not available in parent class
ID: 26794 Comment by: davidc at blesys dot com Reported By: alex_boyer at hotmail dot com Status: Verified Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS-2004-01-11 New Comment: Ah, I see. $that is the old one. I have an ugly solution:?php class A { public $a; function __clone($thatj=''){ if ( $thatj != '' )$that=$thatj; if( $that === null ) die('$that is null'); $this-a = $that-a; } } class B extends A { public $b; function __clone($thatj=''){ if ( $thatj != '' )$that=$thatj; parent::__clone($that); $this-b = $that-b; } } $b = new B(); $b-a = 'AAA'; $b-b = 'BBB'; $clone = $b-__clone(); print_r($clone); ? Previous Comments: [2004-01-11 22:34:21] davidc at blesys dot com Sorry, I don't understand. Is $that a new feature of PHP5? [2004-01-05 09:20:05] alex_boyer at hotmail dot com i mean that $that is not available in parent class A (but IT IS available in class B) [2004-01-05 09:17:14] alex_boyer at hotmail dot com Description: $that is not available in parent class B (uncomment code in class A you will see it). So it is not possible to clone class in a recursive way. Reproduce code: --- class A { public $a; function __clone(){ //if( $that === null ) die('$that is null'); $this-a = $that-a; } } class B extends A { public $b; function __clone(){ parent::__clone(); $this-b = $that-b; } } $b = new B(); $b-a = 'AAA'; $b-b = 'BBB'; $clone = $b-__clone(); print_r($clone); Expected result: B Object ( [b] = BBB [a] = AAA ) Actual result: -- B Object ( [b] = BBB [a] = ) -- Edit this bug report at http://bugs.php.net/?id=26794edit=1
#26789 [NEW]: NullPointerException desired
From: davidc at blesys dot com Operating system: (doesn't apply) PHP version: 5.0.0b3 (beta3) PHP Bug Type: Feature/Change Request Bug description: NullPointerException desired Description: I desire a NullPointerException to be thrown, like in Java. Currently, a fatal error triggers, stopping my entire application. Many times an object may be null, but the application can continue. In addition, if an exception were thrown, I could trace it to see why the exception occured. Reproduce code: --- $j=null; $j-someMethod(); Expected result: Fatal error: Call to a member function someMethod() on a non-object in file.php on line 2 -- Edit bug report at http://bugs.php.net/?id=26789edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26789r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26789r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26789r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26789r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26789r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=26789r=needscript Try newer version: http://bugs.php.net/fix.php?id=26789r=oldversion Not developer issue:http://bugs.php.net/fix.php?id=26789r=support Expected behavior: http://bugs.php.net/fix.php?id=26789r=notwrong Not enough info:http://bugs.php.net/fix.php?id=26789r=notenoughinfo Submitted twice:http://bugs.php.net/fix.php?id=26789r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26789r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26789r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26789r=dst IIS Stability: http://bugs.php.net/fix.php?id=26789r=isapi Install GNU Sed:http://bugs.php.net/fix.php?id=26789r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26789r=float
#26698 [NEW]: Thrown exceptions while evaluting argument to pass as parameter crash PHP
From: davidc at bLesys dot com Operating system: Win XP Professional PHP version: 5CVS-2003-12-22 (dev) PHP Bug Type: Reproducible crash Bug description: Thrown exceptions while evaluting argument to pass as parameter crash PHP Description: (bug was not fixed in beta3 also) While evaluting argument 3 to pass to method setProperties, an exception is thrown but any attempt to rethrow this exception/new exception or return from the method crashes PHP. Strangely, no problem is encountered if this exception is thrown while evaluting the first two arguments. The solution for now is to create a local variable that holds the contents of the argument. Then, we simply pass the local variable to the method, but this creates additional work for the programmer. Reproduce code: --- ?php class x { function getFirst(){ throw ( new Exception( No rows present));} } class Proxy { function setProperties($c){} /* public void*/function setObject( $b, $obj, $res){ try { $res=new x(); $this-setProperties($a,$b,$res-getFirst()); } catch(Exception $e) { throw new Exception(Failed to get it!); } } } $p =( new Proxy()); $p-setObject($this,$o,$ret);? Expected result: Thrown exception caught by PHP5's default handler (stack output, etc) Actual result: -- Apache2 dies -- Edit bug report at http://bugs.php.net/?id=26698edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26698r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26698r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26698r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26698r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26698r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=26698r=needscript Try newer version: http://bugs.php.net/fix.php?id=26698r=oldversion Not developer issue:http://bugs.php.net/fix.php?id=26698r=support Expected behavior: http://bugs.php.net/fix.php?id=26698r=notwrong Not enough info:http://bugs.php.net/fix.php?id=26698r=notenoughinfo Submitted twice:http://bugs.php.net/fix.php?id=26698r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26698r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26698r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26698r=dst IIS Stability: http://bugs.php.net/fix.php?id=26698r=isapi Install GNU Sed:http://bugs.php.net/fix.php?id=26698r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26698r=float
#26697 [Com]: calling class_exists on a nonexistent class in __autoload results in segfault
ID: 26697 Comment by: davidc at blesys dot com Reported By: arjen at glas dot its dot tudelft dot nl Status: Open Bug Type: Zend Engine 2 problem Operating System: Linux PHP Version: 5CVS-2003-12-22 (dev) New Comment: What happens, I think, is that __autoload starts recursing endlessly. Do this: $autotracker=false; function __autoload ($n) { global $autotracker; $n=strtolower($n); if ($autotracker==$n)die(Attempting to autoload $n again); $autotracker=$n; //rest of function __autoload }//end __autoload Probably a bug, but rather easy to fix by the client programmer. I think the bug I found today w/ thrown exceptions is much more dangerous (http://bugs.php.net/bug.php?id=26698) because you can't really fix it for all cases. Previous Comments: [2003-12-22 16:03:57] arjen at glas dot its dot tudelft dot nl Description: When calling class_exists on a nonexistent classname in __autoload, you'll get a segfault. This is in beta1, beta2 and beta3 (and now I had the time to create a testcase and do a report). Which ran under apache2 (2.0.48) on gentoo linux. And then I saw this report: http://bugs.php.net/bug.php?id=26630edit=2 So I downloaded the php5-20031030 snapshot and there it also segfaults... Reproduce code: --- ? function __autoload($classname) { if(!class_exists('test')) { echo This won't be reached due to a segfault; } } $test = new test(); ? -- Edit this bug report at http://bugs.php.net/?id=26697edit=1