[suspicious - maybe spam] #31451 [Opn]: __call can not work with __get

From: Date: Sat, 08 Jan 2005 12:28:01 +0000
Subject: [suspicious - maybe spam] #31451 [Opn]: __call can not work with __get
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-71604@lists.php.net to get a copy of this message
 ID:               31451
 User updated by:  syre at citiz dot net
 Reported By:      syre at citiz dot net
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: win2k pro sp4
 PHP Version:      4.3.10
 New Comment:

the code will ok on the recent snapshot
but if add a new overload method into class ObjectShell,

function func1($a, $b){
	echo "func1() called. ";
	return $this->_target->func1($a, $b);
}

the programme will crashed


Previous Comments:
------------------------------------------------------------------------

[2005-01-08 13:06:17] syre at citiz dot net

the code is
<?php
/**
* add a shell on an object
*/
class ObjectShell {
	var $_target;
	
	function ObjectShell(&$target) {
		$this->_target=$target;
		overload('ObjectShell');
	}

	function __get($name, &$value) {
		$value=$this->_target->$name;
		return true;	
	}

	function __set($name, &$value) {
		$this->_target->$name=$value;
		return true;
	}
	
	function __call($func, $args, &$return) {
		if(method_exists($this->_target, $func)) {
			$return =call_user_func_array(array(&$this->_target, $func),
$args);
			return true;
		}else{
			return false;
		}
	}
}

class Test {
	var $var1=1024;
	function func1($a,$b) {
		return $a + $b;
	}
}

$t=new Test;
$p=new ObjectShell($t);
//this will work
echo $p->var1;
echo "<br>\n";
echo $p->func1(9,7);
//this will result "script time out" on php4.3.10
//but it is ok on 4.3.8 / 4.3.2
//if remove __get, __set£¬it will also work ok
echo $p->func1(9,7);
echo "<br>\n";
echo $p->var1;


?>

------------------------------------------------------------------------

[2005-01-08 12:59:28] sniper@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

..and there is no code in the given url that we could run with our own
PHP builds..


------------------------------------------------------------------------

[2005-01-08 12:18:49] syre at citiz dot net

Description:
------------
//that will ok
echo $p->var1;
echo "<br>\n";
echo $p->func1(9,7);

//that will cost script time out
//the same code will ok on 4.3.8 / 4.3.2
echo $p->func1(9,7);
echo "<br>\n";
echo $p->var1;

Reproduce code:
---------------
http://community.csdn.net/Expert/topic/3707/3707113.xml?temp=.141308



Expected result:
----------------
1024<br>
16<br>
16<br>
1024

Actual result:
--------------
script time out


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31451&edit=1


Thread (10 messages)

« previous php.bugs (#71604) next »