]> granicus.if.org Git - php/commitdiff
- Fixed bug #50383 (Exceptions thrown in __call / __callStatic do not include file...
authorFelipe Pena <felipe@php.net>
Sun, 7 Mar 2010 02:17:11 +0000 (02:17 +0000)
committerFelipe Pena <felipe@php.net>
Sun, 7 Mar 2010 02:17:11 +0000 (02:17 +0000)
NEWS
Zend/tests/bug50383.phpt [new file with mode: 0644]
Zend/zend_builtin_functions.c

diff --git a/NEWS b/NEWS
index 103d5d92770dd928bf3e23397f96c13b980b9ec4..8f32f562ac4b37188c67dbc56932fee9caff40c0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,8 @@ PHP                                                                        NEWS
 - Fixed bug #50810 (property_exists does not work for private). (Felipe)
 - Fixed bug #50731 (Inconsistent namespaces sent to functions registered with
   spl_autoload_register). (Felipe)
+- Fixed bug #50383 (Exceptions thrown in __call / __callStatic do not include
+  file and line in trace). (Felipe)
 - Fixed bug #50358 (Compile failure compiling ext/phar/util.lo). (Felipe)
 
 ?? ??? 20??, PHP 5.3.2
diff --git a/Zend/tests/bug50383.phpt b/Zend/tests/bug50383.phpt
new file mode 100644 (file)
index 0000000..2210c4b
--- /dev/null
@@ -0,0 +1,130 @@
+--TEST--
+Bug #50383 (Exceptions thrown in __call / __callStatic do not include file and line in trace)
+--FILE--
+<?php
+
+class myClass {
+       public static function __callStatic($method, $args) {
+               throw new Exception("Missing static method '$method'\n");
+       }
+       public function __call($method, $args) {
+               throw new Exception("Missing method '$method'\n");
+       }
+}
+
+function thrower() {
+       myClass::ThrowException();
+}
+function thrower2() {
+       $x = new myClass;
+       $x->foo();
+}
+
+try {
+       thrower();
+} catch(Exception $e) {
+       print $e->getMessage();
+       print_r($e->getTrace());
+}
+
+try {
+       thrower2();
+} catch (Exception $e) {
+       print $e->getMessage();
+       print_r($e->getTrace());
+}
+
+?>
+--EXPECTF--
+Missing static method 'ThrowException'
+Array
+(
+    [0] => Array
+        (
+            [file] => %s
+            [line] => 13
+            [function] => __callStatic
+            [class] => myClass
+            [type] => ::
+            [args] => Array
+                (
+                    [0] => ThrowException
+                    [1] => Array
+                        (
+                        )
+
+                )
+
+        )
+
+    [1] => Array
+        (
+            [file] => %s
+            [line] => 13
+            [function] => ThrowException
+            [class] => myClass
+            [type] => ::
+            [args] => Array
+                (
+                )
+
+        )
+
+    [2] => Array
+        (
+            [file] => %s
+            [line] => 21
+            [function] => thrower
+            [args] => Array
+                (
+                )
+
+        )
+
+)
+Missing method 'foo'
+Array
+(
+    [0] => Array
+        (
+            [file] => %s
+            [line] => 17
+            [function] => __call
+            [class] => myClass
+            [type] => ->
+            [args] => Array
+                (
+                    [0] => foo
+                    [1] => Array
+                        (
+                        )
+
+                )
+
+        )
+
+    [1] => Array
+        (
+            [file] => %s
+            [line] => 17
+            [function] => foo
+            [class] => myClass
+            [type] => ->
+            [args] => Array
+                (
+                )
+
+        )
+
+    [2] => Array
+        (
+            [file] => %s
+            [line] => 28
+            [function] => thrower2
+            [args] => Array
+                (
+                )
+
+        )
+
+)
index 4c96e199751479ad06c7f65312913fb21d95fe0c..0807341f527fcd275d066085080a40d51d46613b 100644 (file)
@@ -2148,7 +2148,9 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
 
                        while (prev) {
                                if (prev->function_state.function &&
-                                       prev->function_state.function->common.type != ZEND_USER_FUNCTION) {
+                                       prev->function_state.function->common.type != ZEND_USER_FUNCTION &&
+                                       !(prev->function_state.function->common.type == ZEND_INTERNAL_FUNCTION &&
+                                               (prev->function_state.function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER))) {
                                        break;
                                }                                   
                                if (prev->op_array) {