Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > #29617 : call_user_func_array doesn't handle correctly Exceptions
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 31st July 10:54
php-bugs
External User
 
Posts: 1
Default #29617 : call_user_func_array doesn't handle correctly Exceptions



ID: 29617
Comment by: php dot net at benjamin dot schulz dot name
Reported By: jpbarrette at savoirfairelinux dot net
Status: Open
Bug Type: Scripting Engine problem
Operating System: Mandrake linux 10.0 (Community)
PHP Version: 5.0.0
New Comment:

this is 5.0.1 here


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

[2004-08-16 06:42:46] php dot net at benjamin dot schulz dot name

i experienced this problem, too:
Sample Code:
------------
<?php

function foo()
{
throw new Exception();
}

try {
foo();
} catch(Exception $e) {
echo __LINE__, '<br />';
}

try {
call_user_func('foo');
} catch(Exception $e) {
echo __LINE__, '<br />';
}

try {
call_user_func_array('foo', array());
} catch(Exception $e) {
echo __LINE__, '<br />';
}

?>

Expected Result
---------------
11
17
23

Actual Result
-------------
11
17

Warning: call_user_func_array() [function.call-user-func-array]: Unable
to call foo() in /home/eskaly/dev/test.php on line 27
23

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

[2004-08-11 17:26:48] jpbarrette at savoirfairelinux dot net

The fixed code:

<?php

function test($test) {
throw new Exception("This is a " . $test);
}

call_user_func_array("test", array("test"));

?>

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

[2004-08-11 17:23:22] derick@php.net

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try avoid embedding huge scripts into the report.

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

[2004-08-11 16:58:55] jpbarrette at savoirfairelinux dot net

Description:
------------
If I throw an exception in a function previously called by
call_user_func_array, It produces a warning saying:

Unable to call (the function name)

But the function was correctly called. The same situation
doesn't occur if I use call_user_func instead.

Reproduce code:
---------------
<?php

function test($test) {
throw new Exception("This is a " . $test);
}

call_user_func_array("test", array("test"));


Expected result:
----------------


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


--
Edit this bug report at http://bugs.php.net/?id=29617&edit=1
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666