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.
This commit is contained in:
Dylan K. Taylor 2023-04-21 15:38:11 +01:00
parent 674b65f789
commit f9318bf286
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -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);
}