#29617 [Com]: call_user_func_array doesn't handle correctly Exceptions

From: Date: Wed, 18 Aug 2004 23:34:29 +0000
Subject: #29617 [Com]: call_user_func_array doesn't handle correctly Exceptions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-64901@lists.php.net to get a copy of this message
ID: 29617 Comment by: JustinHagstrom at yahoo dot com 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 bug was already reported here: http://bugs.php.net/bug.php?id=28934 Previous Comments: ------------------------------------------------------------------------ [2004-08-16 06:44:25] php dot net at benjamin dot schulz dot name this is 5.0.1 here ------------------------------------------------------------------------ [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

« previous php.bugs (#64901) next »