From 1bcc07135519a99f086ccb6bab27c5a294f399fe Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Thu, 8 Feb 2024 12:39:24 +1300 Subject: [PATCH] FIX Identify correct class/method for query trace --- code/Extension/ProxyDBExtension.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/code/Extension/ProxyDBExtension.php b/code/Extension/ProxyDBExtension.php index 601a135..8b716fa 100644 --- a/code/Extension/ProxyDBExtension.php +++ b/code/Extension/ProxyDBExtension.php @@ -197,15 +197,21 @@ protected static function findSource() ); $sources = array(); - foreach ($traces as $trace) { + foreach ($traces as $i => $trace) { + // We need to be able to look ahead one item in the trace, because the class/function values + // are talking about what is being *called* on this line, not the function this line lives in. + if (!isset($traces[$i+1])) { + break; + } + $file = isset($trace['file']) ? pathinfo($trace['file'], PATHINFO_FILENAME) : null; - $class = isset($trace['class']) ? $trace['class'] : null; + $class = isset($traces[$i+1]['class']) ? $traces[$i+1]['class'] : null; $line = isset($trace['line']) ? $trace['line'] : null; - $function = isset($trace['function']) ? $trace['function'] : null; - $type = isset($trace['type']) ? $trace['type'] : '::'; + $function = isset($traces[$i+1]['function']) ? $traces[$i+1]['function'] : null; + $type = isset($traces[$i+1]['type']) ? $traces[$i+1]['type'] : '::'; /* @var $object SSViewer */ - $object = isset($trace['object']) ? $trace['object'] : null; + $object = isset($traces[$i+1]['object']) ? $traces[$i+1]['object'] : null; if (in_array($class, $internalClasses)) { continue;