ID:               31190
 Updated by:       [EMAIL PROTECTED]
 Reported By:      phpbugs at domain51 dot net
-Status:           Open
+Status:           Assigned
-Bug Type:         Unknown/Other Function
+Bug Type:         Zend Engine 2 problem
 Operating System: All
 PHP Version:      5CVS-2004-12-20 (dev)
-Assigned To:      
+Assigned To:      andi


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

[2004-12-20 01:45:48] phpbugs at domain51 dot net

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 this bug report at http://bugs.php.net/?id=31190&edit=1

Reply via email to