ID:               36883
 Updated by:       [EMAIL PROTECTED]
 Reported By:      k at phpkoala dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Linux
 PHP Version:      5.1.2
 New Comment:

The result you get is expected and correct.
And this:
            [file] => /home/test.php
            [line] => 13
            [function] => 
            [class] => 
            [type] => 
            [args] => 
is definitely wrong.


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

[2006-03-28 02:46:10] k at phpkoala dot com

Description:
------------
When I call debug_backtrace, I find that the results do not match
expectations. Specifically, the line number does not match the values
for function and class.

As shown below, I would expect to see the line number match the values
for function and class, at the point referenced. If this point is
deemed to be the point where debug_backtrace is called from, then I
would expect the details to show the function and class in scope at the
line number that debug_backtrace was called, and then as the next most
recent entry, the line number etc. for the code that called the
function containing the debug_backtrace command.

Otherwise, if the reported details should ignore the point in the code
that calls debug_backtrace (the current scope at that point) then that
entry should not be reported, and the function and class should be
relative to the line number that called the function.

It would appear that the second of these two options is intended, but
that the function and class are being reported for the scope "now"
(when debug_backtrace is called) rather than "then" (the last call,
i.e. the call to the function) which is what the line number reports.

To further clarify; I would expect the output to match the details that
would be shown if I used __FILE__, __LINE__, __FUNCTION__, __CLASS__ at
each call point. Surely these should all match up...?

I am running dot-deb packages for PHP 5.1.2. No customisations.

This issue also occurs on PHP 4.3.10.

Reproduce code:
---------------
<?php

class test {
        function check1() {
                print_r(debug_backtrace());
        }
        function check2() {
                self::check1();  // Line 8
        }
}

echo "Test 1:\n\n";
test::check1();                  // Line 13

echo "\n\nTest 2:\n\n";
test::check2();                  // Line 16

Expected result:
----------------
Test 1:

Array
(
    [0] => Array
        (
            [file] => /home/test.php
            [line] => 13
            [function] => 
            [class] => 
            [type] => 
            [args] => 

        )

)


Test 2:

Array
(
    [0] => Array
        (
            [file] => /home/test.php
            [line] => 8
            [function] => check2
            [class] => test
            [type] => ::
            [args] => Array
                (
                )

        )

    [1] => Array
        (
            [file] => /home/test.php
            [line] => 16
            [function] => 
            [class] => 
            [type] => 
            [args] => 

        )

)

--------------------  OR  --------------------

Test 1:

Array
(
    [0] => Array
        (
            [file] => /home/test.php
            [line] => 5
            [function] => check1
            [class] => test
            [type] => ::
            [args] => Array
                (
                )

        )

    [1] => Array
        (
            [file] => /home/test.php
            [line] => 13
            [function] => 
            [class] => 
            [type] => 
            [args] => 

        )

)


Test 2:

Array
(
    [0] => Array
        (
            [file] => /home/test.php
            [line] => 5
            [function] => check1
            [class] => test
            [type] => ::
            [args] => Array
                (
                )

        )

    [1] => Array
        (
            [file] => /home/test.php
            [line] => 8
            [function] => check2
            [class] => test
            [type] => ::
            [args] => Array
                (
                )

        )

    [2] => Array
        (
            [file] => /home/test.php
            [line] => 16
            [function] => 
            [class] => 
            [type] => 
            [args] => 

        )

)


Actual result:
--------------
Test 1:

Array
(
    [0] => Array
        (
            [file] => /home/test.php
            [line] => 13
            [function] => check1
            [class] => test
            [type] => ::
            [args] => Array
                (
                )

        )

)


Test 2:

Array
(
    [0] => Array
        (
            [file] => /home/test.php
            [line] => 8
            [function] => check1
            [class] => test
            [type] => ::
            [args] => Array
                (
                )

        )

    [1] => Array
        (
            [file] => /home/test.php
            [line] => 16
            [function] => check2
            [class] => test
            [type] => ::
            [args] => Array
                (
                )

        )

)



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36883&edit=1

Reply via email to