From f9318bf286844829b27ac56bc08d4a1bcfedc138 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 21 Apr 2023 15:38:11 +0100 Subject: [PATCH] TimingsHandler: stop throwing exceptions when timers aren't stopped in the right order this is usually because of an uncaught exception interacting with a try...finally block. This will normally result in a crash anyway, and we don't want to obscure the real error. --- src/timings/TimingsHandler.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/timings/TimingsHandler.php b/src/timings/TimingsHandler.php index b77610a65..be4979f15 100644 --- a/src/timings/TimingsHandler.php +++ b/src/timings/TimingsHandler.php @@ -189,12 +189,12 @@ class TimingsHandler{ } $record = TimingsRecord::getCurrentRecord(); - if($record !== null){ - if($record->getTimerId() !== spl_object_id($this)){ - throw new \LogicException("Timer \"" . $record->getName() . "\" should have been stopped before stopping timer \"" . $this->name . "\""); - } + $timerId = spl_object_id($this); + for(; $record !== null && $record->getTimerId() !== $timerId; $record = TimingsRecord::getCurrentRecord()){ + \GlobalLogger::get()->error("Timer \"" . $record->getName() . "\" should have been stopped before stopping timer \"" . $this->name . "\""); $record->stopTiming($now); } + $record?->stopTiming($now); if($this->parent !== null){ $this->parent->internalStopTiming($now); }