From 7fd2177be63333af83e4135880f4674ae11826a6 Mon Sep 17 00:00:00 2001 From: Ion Bazan Date: Wed, 30 Sep 2020 16:31:32 +0800 Subject: [PATCH 1/4] Fix FrameContextifier --- src/FrameBuilder.php | 2 +- src/StacktraceBuilder.php | 2 +- tests/FrameBuilderTest.php | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/FrameBuilder.php b/src/FrameBuilder.php index 5bbb40b80a..21659f5850 100644 --- a/src/FrameBuilder.php +++ b/src/FrameBuilder.php @@ -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, $this->getFunctionArguments($backtraceFrame), $this->isFrameInApp($file, $functionName) ); diff --git a/src/StacktraceBuilder.php b/src/StacktraceBuilder.php index fc4b66c8d3..d48b2cdf5d 100644 --- a/src/StacktraceBuilder.php +++ b/src/StacktraceBuilder.php @@ -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); } diff --git a/tests/FrameBuilderTest.php b/tests/FrameBuilderTest.php index b73dd3696b..2d0e6e1ec6 100644 --- a/tests/FrameBuilderTest.php +++ b/tests/FrameBuilderTest.php @@ -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 [ @@ -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 [ @@ -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 [ @@ -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 [ @@ -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 [ @@ -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 [ @@ -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'), ]; } From fbea383f9f0ebdacabd55c43d8924123e234574c Mon Sep 17 00:00:00 2001 From: Ion Bazan Date: Fri, 2 Oct 2020 12:00:06 +0800 Subject: [PATCH 2/4] add test --- tests/StacktraceBuilderTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/StacktraceBuilderTest.php b/tests/StacktraceBuilderTest.php index 1e8f0dccf4..544919063b 100644 --- a/tests/StacktraceBuilderTest.php +++ b/tests/StacktraceBuilderTest.php @@ -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()); From 66096e3e06f6571ac68452b75ccf298cf2a7e965 Mon Sep 17 00:00:00 2001 From: Ion Bazan Date: Mon, 5 Oct 2020 22:54:23 +0800 Subject: [PATCH 3/4] add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4903a14796..4e712dc501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Fix stacktrace frames were not contextified (#1104) + ## 3.0.2 (2020-10-02) - fix: Use the traces sample rate for traces instead of the event sample rate (#1106) From bb6dde41c3624d0a9a2ea1c565cacee310dc0a37 Mon Sep 17 00:00:00 2001 From: Stefano Arlandini Date: Mon, 5 Oct 2020 17:30:08 +0200 Subject: [PATCH 4/4] Fix CR issues --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e712dc501..81f70974f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- Fix stacktrace frames were not contextified (#1104) +- 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)