From: Tim Düsterhus Date: Fri, 27 Aug 2021 11:57:26 +0000 (+0200) Subject: Call `finalizeLog` for all exceptions within a chain X-Git-Tag: 5.5.0_Alpha_1~461 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f9a9ccf73955d13f6c034eef29ccce0c5d3adec8;p=GitHub%2FWoltLab%2FWCF.git Call `finalizeLog` for all exceptions within a chain --- 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; }