Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Fix missing source code excerpts for stacktrace frames whose absolute file path is equal to the file path (#1104)

## 3.0.2 (2020-10-02)

- fix: Use the traces sample rate for traces instead of the event sample rate (#1106)
Expand Down
2 changes: 1 addition & 1 deletion src/FrameBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function buildFromBacktraceFrame(string $file, int $line, array $backtrac
$strippedFilePath,
$line,
$rawFunctionName,
Frame::INTERNAL_FRAME_FILENAME !== $file && $strippedFilePath !== $file ? $file : null,
Frame::INTERNAL_FRAME_FILENAME !== $file ? $file : null,
Comment thread
IonBazan marked this conversation as resolved.
$this->getFunctionArguments($backtraceFrame),
$this->isFrameInApp($file, $functionName)
);
Expand Down
2 changes: 1 addition & 1 deletion src/StacktraceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function buildFromBacktrace(array $backtrace, string $file, int $line): S
}

// Add a final stackframe for the first method ever of this stacktrace
array_unshift($frames, new Frame(null, $file, $line));
array_unshift($frames, $this->frameBuilder->buildFromBacktraceFrame($file, $line, []));

return new Stacktrace($frames);
}
Expand Down
14 changes: 7 additions & 7 deletions tests/FrameBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function buildFromBacktraceFrameDataProvider(): \Generator
'line' => 20,
'function' => 'test_function',
],
new Frame('test_function', '/path/to/file', 10),
new Frame('test_function', '/path/to/file', 10, null, '/path/to/file'),
];

yield [
Expand All @@ -46,7 +46,7 @@ public function buildFromBacktraceFrameDataProvider(): \Generator
'line' => 20,
'function' => 'test_function',
],
new Frame('test_function', '/path/to/file', 10),
new Frame('test_function', '/path/to/file', 10, null, '/path/to/file'),
];

yield [
Expand All @@ -57,7 +57,7 @@ public function buildFromBacktraceFrameDataProvider(): \Generator
'function' => 'test_function',
'class' => 'TestClass',
],
new Frame('TestClass::test_function', '/path/to/file', 10, 'TestClass::test_function'),
new Frame('TestClass::test_function', '/path/to/file', 10, 'TestClass::test_function', '/path/to/file'),
];

yield [
Expand All @@ -67,7 +67,7 @@ public function buildFromBacktraceFrameDataProvider(): \Generator
'line' => 10,
'function' => 'test_function',
],
new Frame('test_function', '/path/to/file', 10),
new Frame('test_function', '/path/to/file', 10, null, '/path/to/file'),
];

yield [
Expand All @@ -78,7 +78,7 @@ public function buildFromBacktraceFrameDataProvider(): \Generator
'function' => 'test_function',
'class' => "class@anonymous\0/path/to/file",
],
new Frame("class@anonymous\0/path/to/file::test_function", '/path/to/file', 10, "class@anonymous\0/path/to/file::test_function"),
new Frame("class@anonymous\0/path/to/file::test_function", '/path/to/file', 10, "class@anonymous\0/path/to/file::test_function", '/path/to/file'),
];

yield [
Expand Down Expand Up @@ -133,7 +133,7 @@ public function buildFromBacktraceFrameDataProvider(): \Generator
'file' => 'path/not/of/app/path/to/file',
'line' => 10,
],
new Frame(null, 'path/not/of/app/path/to/file', 10, null),
new Frame(null, 'path/not/of/app/path/to/file', 10, null, 'path/not/of/app/path/to/file'),
];

yield [
Expand All @@ -147,7 +147,7 @@ public function buildFromBacktraceFrameDataProvider(): \Generator
'file' => 'path/not/of/app/to/file',
'line' => 10,
],
new Frame(null, 'path/not/of/app/to/file', 10, null),
new Frame(null, 'path/not/of/app/to/file', 10, null, 'path/not/of/app/to/file'),
];
}

Expand Down
2 changes: 2 additions & 0 deletions tests/StacktraceBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ public function testBuildFromBacktrace(): void

$this->assertNull($frames[0]->getFunctionName());
$this->assertSame('/in/jXVmi', $frames[0]->getFile());
$this->assertSame('/in/jXVmi', $frames[0]->getAbsoluteFilePath());
$this->assertSame(5, $frames[0]->getLine());

$this->assertSame('{closure}', $frames[1]->getFunctionName());
$this->assertSame('/in/jXVmi', $frames[1]->getFile());
$this->assertSame('/in/jXVmi', $frames[1]->getAbsoluteFilePath());
$this->assertSame(9, $frames[1]->getLine());

$this->assertSame('main', $frames[2]->getFunctionName());
Expand Down