]> granicus.if.org Git - php/commitdiff
MFH: Fix bug #44487 (call_user_method_array issues a warning when throwing an exception).
authorDavid Soria Parra <dsp@php.net>
Thu, 20 Mar 2008 00:55:26 +0000 (00:55 +0000)
committerDavid Soria Parra <dsp@php.net>
Thu, 20 Mar 2008 00:55:26 +0000 (00:55 +0000)
NEWS
ext/standard/basic_functions.c
ext/standard/tests/general_functions/bug44487.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 629e0121d3f3e5e338f92f4b569cbbcc86d94bbd..f7898b0da0627121f0799412df3a5fef5779709f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,8 @@ PHP                                                                        NEWS
   again...). (Felipe)
 - Fixed bug #41828 (Failing to call RecursiveIteratorIterator::__construct() 
   causes a sefault). (Etienne)
+- Fixed bug #44487 (call_user_method_array issues a warning when throwing
+   an exception). (David Soria Parra)
 
 06 Mar 2008, PHP 5.2.6RC2
 - Fixed bug #44333 (SEGFAULT when using mysql_pconnect() with client_flags).
index 7a07b0a61238f8dceca5211b9cddf6e4da095d19..cec0b1f636c4289a48d193ad94cdde07574e1559 100644 (file)
@@ -5219,8 +5219,10 @@ PHP_FUNCTION(call_user_method)
        SEPARATE_ZVAL(params[0]);
        convert_to_string(*params[0]);
 
-       if (call_user_function_ex(EG(function_table), params[1], *params[0], &retval_ptr, arg_count-2, params+2, 0, NULL TSRMLS_CC) == SUCCESS && retval_ptr) {
-               COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+       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) {
+                       COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+               }
        } else {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call %s()", Z_STRVAL_PP(params[0]));
        }
@@ -5261,8 +5263,10 @@ PHP_FUNCTION(call_user_method_array)
                element++;
        }
        
-       if (call_user_function_ex(EG(function_table), obj, *method_name, &retval_ptr, num_elems, method_args, 0, NULL TSRMLS_CC) == SUCCESS && retval_ptr) {
-               COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+       if (call_user_function_ex(EG(function_table), obj, *method_name, &retval_ptr, num_elems, method_args, 0, NULL TSRMLS_CC) == SUCCESS)  {
+               if (retval_ptr) {
+                       COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+               }
        } else {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call %s()", Z_STRVAL_PP(method_name));
        }
diff --git a/ext/standard/tests/general_functions/bug44487.phpt b/ext/standard/tests/general_functions/bug44487.phpt
new file mode 100644 (file)
index 0000000..10c52c6
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Bug #44487 (call_user_method_array issues a warning when throwing an exception)
+--INI--
+error_reporting = E_ALL & ~E_DEPRECATED
+--FILE--
+<?php
+
+class Foo
+{
+        public function test()
+        {
+                print 'test';
+                throw new Exception();
+        }
+}
+
+try {
+        $bar = new Foo();
+        call_user_method_array('test', $bar, array()) ;
+} catch (Exception $e) {
+}
+?>
+--EXPECT--
+test