Open lc1337 opened 1 month ago
Just found out that this may actually be a correct behaviour.
According to https://www.php.net/manual/en/function.debug-backtrace.php , "file" of debug_backtrace() result is related to __FILE__
constant which, according to https://www.php.net/manual/en/language.constants.magic.php#constant.file, should really be a full path with symlinks resolved.
However is this really wanted to have a resolved path in stack traces? For example it causes troubles when debuging in IDE, which opens the related files in out of project context.
However is this really wanted to have a resolved path in stack traces? For example it causes troubles when debuging in IDE, which opens the related files in out of project context.
Personally, I think it's necessary. If use symbolic links for traces, I'm not sure what should happen if use unlink to remove the symbolic links in the process.
edit: I think can probably come up with a consistent specification, but can expect the implementation to be more complicated than it is now. If you think the change is worth the complexity, it's probably best to discuss it on the mailing list.
Just found out that this may actually be a correct behaviour.
Yeah, so I'm changing this ticket to a feature request.
If you think the change is worth the complexity, it's probably best to discuss it on the mailing list.
I agree.
And for clarification: I don't think this behavior is Windows specific. Can anybody confirm?
assuming the mklink /D (/d ?) means soft link. this is what I get on mac
array(1) {
[0]=>
string(11) "d1/test.php"
}
array(1) {
[0]=>
array(4) {
["file"]=>
string(24) "/private/tmp/d2/test.php"
["line"]=>
int(7)
["function"]=>
string(9) "{closure}"
["args"]=>
array(0) {
}
}
}
so yes same outcome.
For example there could be an option to show stack traces with both symlinks and evaluated paths like this:
D:\d1\test.php (symlink) =>
D:\d3\test.php (symlink) =>
D:\d2\test.php:45
That would provide some additional debug info and also solved the IDE issue which would be now able to work with the files in right context.
Description
Summary
Stack trace (from debug_backtrace(), exceptions, errors ..) shows always absolute/real/evaluated file paths, even though the script was run from symlink context.
How to reproduce
var_dump($argv);
(function(){ var_dump(debug_backtrace()); })();
array(1) { [0]=> string(14) "D:\d1\test.php" } array(1) { [0]=> array(4) { ["file"]=> string(14) "D:\d2\test.php" ["line"]=> int(8) ["function"]=> string(9) "{closure}" ["args"]=> array(0) { } } }
array(1) { [0]=> string(14) "D:\d1\test.php" } array(1) { [0]=> array(4) { ["file"]=> string(14) "D:\d1\test.php" ["line"]=> int(8) ["function"]=> string(9) "{closure}" ["args"]=> array(0) { } } } ...