]> granicus.if.org Git - php/commitdiff
Bugfix #25038 (call_user_func issues warning if function throws exception)
authorMarcus Boerger <helly@php.net>
Sat, 27 Dec 2003 21:10:34 +0000 (21:10 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 27 Dec 2003 21:10:34 +0000 (21:10 +0000)
NEWS
ext/standard/basic_functions.c
ext/standard/tests/general_functions/bug25038.phpt [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index ee0facd2ec4851c2bd9b9044df025dacf0a2f2ec..8863d52844871cc119697bd8740a55453088a2e4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ PHP                                                                        NEWS
   (Ilia)
 - Fixed bug #26680 (Added version check in mysqli_report_index) (Georg)
 - Fixed bug #26675 (Segfault on ArrayAccess use). (Marcus)
+- Fixed bug #25038 (call_user_func issues warning if function throws 
+  exception). (Marcus)
 
 21 Dec 2003, PHP 5 Beta 3
 - Bundled new tidy extension (John, Wez)
index 3850c48803209c0b9fbcec6034a7aeb39a43dc3a..17ae1145020d9eef7a888e10312c950827f13e9e 100644 (file)
@@ -1830,8 +1830,10 @@ PHP_FUNCTION(call_user_func)
                RETURN_NULL();
        }
 
-       if (call_user_function_ex(EG(function_table), NULL, *params[0], &retval_ptr, argc-1, params+1, 0, NULL TSRMLS_CC) == SUCCESS && retval_ptr) {
-               COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+       if (call_user_function_ex(EG(function_table), NULL, *params[0], &retval_ptr, argc-1, params+1, 0, NULL TSRMLS_CC) == SUCCESS) {
+               if (retval_ptr) {
+                       COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+               }
        } else {
                if (argc > 1) {
                        SEPARATE_ZVAL(params[1]);
diff --git a/ext/standard/tests/general_functions/bug25038.phpt b/ext/standard/tests/general_functions/bug25038.phpt
new file mode 100755 (executable)
index 0000000..52fe032
--- /dev/null
@@ -0,0 +1,32 @@
+--TEST--
+Bug #25038 (call_user_func issues warning if function throws exception)
+--FILE--
+<?php
+
+function bar($x='no argument')
+{
+    throw new Exception("This is an exception from bar({$x}).");
+}
+try
+{
+       bar('first try');
+}
+catch (Exception $e)
+{
+       print $e->getMessage()."\n";
+}
+try
+{
+       call_user_func('bar','second try');
+}
+catch (Exception $e)
+{
+       print $e->getMessage()."\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+This is an exception from bar(first try).
+This is an exception from bar(second try).
+===DONE===