#25038 [Com]: call_user_func issues warning if function throws exception

From: Date: Wed, 08 Oct 2003 11:59:47 +0000
Subject: #25038 [Com]: call_user_func issues warning if function throws exception
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-48724@lists.php.net to get a copy of this message
ID: 25038 Comment by: rep at devdomain dot com Reported By: tater at potatoe dot com Status: Open Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS-2003-08-11 (dev) New Comment: same here with call_user_func_array: call_user_func_array fails when the method throws an exception issuing a php warning, and the exception is lost in the process. try { $mValue = call_user_func_array ($func, $params); // func throws exception, php warning issued } catch (devException $oExc) { // never gets here } Previous Comments: ------------------------------------------------------------------------ [2003-08-11 06:35:02] tater at potatoe dot com Description: ------------ Throwing an exception from a function called by call_user_func() causes a warning to be issued, saying it was unable to call the function. An odd side note: if I set up my own error handler, it does not receive this warning. Kind of an inadvertant workaround for now... Reproduce code: --------------- function bar($x='no argument') { throw new Exception("This is an exception from bar({$x})."); } try { bar('first try'); } catch (Exception $e) { print "{$e->message}\n"; } try { call_user_func('bar','second try'); } catch (Exception $e) { print "{$e->message}\n"; } Expected result: ---------------- This is an exception from bar(first try). This is an exception from bar(second try). Actual result: -------------- This is an exception from bar(first try). Warning: call_user_func(bar): Unable to call bar(second try) in /my/pathname/test.php on line 8 This is an exception from bar(second try). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25038&edit=1

« previous php.bugs (#48724) next »