From 64a1aeeedf734b89d83522b33702f09eff019d9a Mon Sep 17 00:00:00 2001 From: Dawid Polak Date: Thu, 4 Jan 2018 15:01:44 +0100 Subject: [PATCH 1/2] default value for array should be array - fix notice array_key_exists() expects parameter 2 to be array, null given --- lib/Raven/Stacktrace.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Raven/Stacktrace.php b/lib/Raven/Stacktrace.php index c3353d799..ab522f5eb 100644 --- a/lib/Raven/Stacktrace.php +++ b/lib/Raven/Stacktrace.php @@ -35,8 +35,8 @@ public static function get_stack_info($frames, */ $result = array(); for ($i = 0; $i < count($frames); $i++) { - $frame = isset($frames[$i]) ? $frames[$i] : null; - $nextframe = isset($frames[$i + 1]) ? $frames[$i + 1] : null; + $frame = isset($frames[$i]) ? $frames[$i] : array(); + $nextframe = isset($frames[$i + 1]) ? $frames[$i + 1] : array(); if (!array_key_exists('file', $frame)) { $context = array(); From b277bb45f9a634dfa50ddc6e723c1e9b62b12543 Mon Sep 17 00:00:00 2001 From: Dawid Polak Date: Fri, 5 Jan 2018 13:37:59 +0100 Subject: [PATCH 2/2] Test for Raven_Stacktrace - testInAppWithEmptyFrame --- lib/Raven/Stacktrace.php | 4 +++- test/Raven/Tests/StacktraceTest.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Raven/Stacktrace.php b/lib/Raven/Stacktrace.php index ab522f5eb..945e68d57 100644 --- a/lib/Raven/Stacktrace.php +++ b/lib/Raven/Stacktrace.php @@ -50,8 +50,10 @@ public static function get_stack_info($frames, } catch (ReflectionException $e) { // Forget it if we run into errors, it's not worth it. } - } else { + } elseif (!empty($frame['function'])) { $context['line'] = sprintf('%s(anonymous)', $frame['function']); + } else { + $context['line'] = sprintf('(anonymous)'); } if (empty($context['filename'])) { diff --git a/test/Raven/Tests/StacktraceTest.php b/test/Raven/Tests/StacktraceTest.php index c0f3c4cdc..641cc1128 100644 --- a/test/Raven/Tests/StacktraceTest.php +++ b/test/Raven/Tests/StacktraceTest.php @@ -192,6 +192,20 @@ public function testInAppWithAnonymous() $this->assertEquals($frames[0]['in_app'], false); } + public function testInAppWithEmptyFrame() + { + $stack = array( + array( + "function" => "{closure}", + ), + null + ); + + $frames = Raven_Stacktrace::get_stack_info($stack, true, null, 0, null, dirname(__FILE__)); + + $this->assertEquals($frames[0]['in_app'], false); + } + public function testInAppWithExclusion() { $stack = array(