ID: 28713
User updated by: rodolfo at rodsoft dot org
Reported By: rodolfo at rodsoft dot org
Status: Bogus
Bug Type: Reproducible crash
Operating System: linux 2.6.6
PHP Version: 5.0.0RC2
New Comment:
You're right, but the __set and __get functions manage to get around
this problem by not allowing you to access an undefined property inside
them (which would cause recursive calling of itself). Wouldn't it be
logical to extend this behaviour to __call, not allowing one to call an
undefined member inside it? The way it is now can lead to situations
like this:
class myclass
{
function test() {} // Comment this line out and php
// will crash. Very hard bug to trace
// when working on a big class.
function __call($func, $args)
{
$this->test();
}
};
Previous Comments:
------------------------------------------------------------------------
[2004-06-10 08:58:15] [EMAIL PROTECTED]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
The only way in which PHP is allowed to crash is in this case:
unlimited recursive calling of functions.
------------------------------------------------------------------------
[2004-06-09 20:05:35] rodolfo at rodsoft dot org
Description:
------------
This ill-behaved code crashes php. I know one should never write things
like this, but this sample is an oversimplified version of a much
bigger code I'm working with, and I've just spot my error after trying
to simplify the code to attach here. PHP should emmit a warning when
such things happen, as with __set and __get, saying that $this->func()
isn't defined, when called inside a __call handler.
Reproduce code:
---------------
<?
class test
{
function __call($func, $args)
{
$this->hello();
}
}
$a = new test;
$a->hello();
echo "You won't read this";
?>
Expected result:
----------------
A warning saying that $this->hello isn't defined.
Actual result:
--------------
The coredump is a bunch of
#0 0x0821d843 in zend_call_function ()
#1 0x0821e76a in call_user_function_ex ()
#2 0x0823cfa5 in zend_std_call_user_call ()
#3 0x0825f8ee in zend_do_fcall_common_helper ()
#4 0x0825faf1 in zend_do_fcall_by_name_handler ()
#5 0x0824daf8 in execute ()
repeated over and over
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28713&edit=1