]> granicus.if.org Git - php/commitdiff
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:50:47 +0000 (00:50 +0000)
committerDavid Soria Parra <dsp@php.net>
Thu, 20 Mar 2008 00:50:47 +0000 (00:50 +0000)
ext/standard/basic_functions.c
ext/standard/tests/general_functions/bug44487.phpt [new file with mode: 0644]

index df1394f1435fb1353ffdf30d423f476cfed73169..c329e724be2e7e8c4a67eedc7fe01bac64c364cc 100644 (file)
@@ -5140,8 +5140,10 @@ PHP_FUNCTION(call_user_method)
 
        convert_to_text(callback);
 
-       if (call_user_function_ex(EG(function_table), &object, callback, &retval_ptr, n_params, params, 0, NULL TSRMLS_CC) == SUCCESS && retval_ptr) {
-               COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+       if (call_user_function_ex(EG(function_table), &object, callback, &retval_ptr, n_params, params, 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 %R()", Z_TYPE_P(callback), Z_UNIVAL_P(callback));
        }
@@ -5183,8 +5185,10 @@ PHP_FUNCTION(call_user_method_array)
                element++;
        }
 
-       if (call_user_function_ex(EG(function_table), &object, callback, &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), &object, callback, &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 %R()", Z_TYPE_P(callback), Z_UNIVAL_P(callback));
        }
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