From f9a9ccf73955d13f6c034eef29ccce0c5d3adec8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 27 Aug 2021 13:57:26 +0200 Subject: [PATCH] Call `finalizeLog` for all exceptions within a chain --- wcfsetup/install/files/lib/core.functions.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/lib/core.functions.php b/wcfsetup/install/files/lib/core.functions.php index cb5758411d..f98bb53f37 100644 --- a/wcfsetup/install/files/lib/core.functions.php +++ b/wcfsetup/install/files/lib/core.functions.php @@ -254,13 +254,17 @@ namespace wcf\functions\exception { file_put_contents($logFile, $entry, FILE_APPEND); // let the Exception know it has been logged - if ( - $e instanceof ILoggingAwareException - || (method_exists($e, 'finalizeLog') && is_callable([$e, 'finalizeLog'])) - ) { - /** @var ILoggingAwareException $e */ - $e->finalizeLog($exceptionID, $logFile); + $prev = $e; + do { + if ( + $prev instanceof ILoggingAwareException + || (method_exists($prev, 'finalizeLog') && is_callable([$prev, 'finalizeLog'])) + ) { + /** @var ILoggingAwareException $prev */ + $prev->finalizeLog($exceptionID, $logFile); + } } + while ($prev = $prev->getPrevious()); return $exceptionID; } -- 2.20.1