#31190 [NEW]: call_user_func_array(), exceptions, and the patch

From: Date: Mon, 20 Dec 2004 00:45:50 +0000
Subject: #31190 [NEW]: call_user_func_array(), exceptions, and the patch
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-70661@lists.php.net to get a copy of this message
From: phpbugs at domain51 dot net Operating system: All PHP version: 5CVS-2004-12-20 (dev) PHP Bug Type: Unknown/Other Function Bug description: call_user_func_array(), exceptions, and the patch Description: ------------ call_user_func_array() uses a compounded if() statement on line 1996 in file ext/standard/basic_functions.c of the current CVS snapshot (200412192330) and v5.0.3 Stable which catches the Exceptions improperly. call_user_func() does not have this compounded if() statement, and works properly. To fix the code, change the following if statement: if (call_user_function_ex(EG(function_table), NULL, *func, &retval_ptr, count, func_params, 0, NULL TSRMLS_CC) == SUCCESS && retval_ptr) { To: if (call_user_function_ex(EG(function_table), params[1], *params[0], &retval_ptr, arg_count-2, params+2, 0, NULL TSRMLS_CC) == SUCCESS) { if (retval_ptr) { NOTE: This is a duplicate of #28934, which has had this same bug fix in it since early September prior to v5.0.2. I'm opening a new report in hopes that it will bring attention to this known bugfix this will fixed in the CVS and adopted prior the next version of PHP 5.0.x. Reproduce code: --------------- <?php class test { function throwException() { throw new Exception("Hello World!\n"); } } $array = array(new test(), 'throwException'); try { call_user_func($array, 1, 2); } catch (Exception $e) { echo $e->getMessage(); } try { call_user_func_array($array, array(1, 2)); } catch (Exception $e) { echo $e->getMessage(); } Expected result: ---------------- $ php -f call_user_func.php Hello World! Hello World! Actual result: -------------- $ php -f call_user_func.php Hello World! <br /> <b>Warning</b>: call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: Unable to call test::throwException() in <b>/home/tswicegood/Desktop/BrainDump/phpbin/call_user_func.php</b> on line <b>19</b><br /> Hello World! -- Edit bug report at http://bugs.php.net/?id=31190&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31190&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31190&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31190&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31190&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31190&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31190&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31190&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31190&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31190&r=support Expected behavior: http://bugs.php.net/fix.php?id=31190&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31190&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31190&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31190&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31190&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31190&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31190&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31190&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31190&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=31190&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=31190&r=mysqlcfg

« previous php.bugs (#70661) next »