PHP 4.0 Bug #6354: A property making trouble

From: Date: Fri, 25 Aug 2000 15:26:49 +0000
Subject: PHP 4.0 Bug #6354: A property making trouble
Groups: php.dev 
Request: Send a blank email to php-dev+get-30654@lists.php.net to get a copy of this message
From: k.reimer@twisd.de Operating system: Linux PHP version: 4.0.1pl2 PHP Bug Type: Misbehaving function Bug description: A property making trouble Well, I think this has something to do with bug #6352 I have posted today. A very strange behaviour. Here is the source: <?php class CBase { var $aChildren=array(); function CBase($hParent=0) { if ($hParent!=0) $hParent->addChildren(&$this); } function addChildren($Children) { $this->aChildren[]=&$Children; } function draw() { $this->drawChildren(); } function drawChildren() { for ($iCount=0;$iCount<count($this->aChildren);$iCount++) $this->aChildren[$iCount]->draw(); } function printMe($sValue) { printf($sValue); } } class CBaseExt extends CBase { var $sBugMaker; function draw() { $this->printMe($this->sBugMaker); $this->drawChildren(); } } class CChild extends CBase { function draw() { printf("It's working!<br>\n"); } } class CParent extends CBaseExt { function CParent($Parent=0) { // Comment me out, and I will work... $this->sBugMaker="I'm the trouble maker"; $this->Table=new CChild(&$this); } } $Page=new CParent(); $Page->draw(); ?> This script creates the class Parent. The constructor of the Parent creates a child. If I draw the Parent, the Child is drawn, too. This code produces the follwoing error: Fatal error: Call to a member function on a non-object in /var/www/ailis.de/bugs/bug.php on line 20 Looks like I have an error in my script, but... If I comment out the line where I write something in the Property $sTroubleMaker, the script is working. I can't imagine that this is an error in my script. This line seems to be messing around ALOT, if I extend the script to do a lot of normal tasks with classes, it produces Segfaults. And again, if I remove the line, all is working perfectly. You can test this behaviour. I have published this script with and without error here: http://www.ailis.de/bugs/bug.php http://www.ailis.de/bugs/nobug.php bug.txt und nobug.txt are symbolic links to these files, so you can read the source code. I have reproduced this bug on three different machines. All are running apache 1.3.9 and php 4.01pl2 under linux. Maybe you can reproduce another strange behaviour: Load the nobug.php-Link from above in to a browser. The script is working. Now hit reload and it maybe that you get the same error message if loading bug.php. I can reproduce this with Netscape, but not with Konqueror. Really strange. Bye K

« previous php.dev (#30654) next »