From 8878877cf978be650e5d256c7ab02bc0ff21adfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Thu, 21 Feb 2019 12:55:04 +0100 Subject: [PATCH 1/2] Fix exception loop in QueueConsumer --- pkg/enqueue/Consumption/QueueConsumer.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/enqueue/Consumption/QueueConsumer.php b/pkg/enqueue/Consumption/QueueConsumer.php index 58b8fa06c..19871599c 100644 --- a/pkg/enqueue/Consumption/QueueConsumer.php +++ b/pkg/enqueue/Consumption/QueueConsumer.php @@ -317,18 +317,16 @@ private function onProcessorException(ExtensionInterface $extension, Consumer $c return $result; } catch (\Exception $e) { - $wrapper = $e; - while ($prev = $wrapper->getPrevious()) { + $prev = $e; + do { if ($exception === $wrapper = $prev) { throw $e; } - } + } while ($prev = $wrapper->getPrevious()); - if ($exception !== $wrapper) { - $prev = new \ReflectionProperty('Exception', 'previous'); - $prev->setAccessible(true); - $prev->setValue($wrapper, $exception); - } + $prev = new \ReflectionProperty($wrapper instanceof \Exception ? \Exception::class : \Error::class, 'previous'); + $prev->setAccessible(true); + $prev->setValue($wrapper, $exception); throw $e; } From 274aa0fdd41c00dbcc4529f88f2d580fb973c4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Thu, 21 Feb 2019 13:06:01 +0100 Subject: [PATCH 2/2] Improve comment --- pkg/enqueue/Consumption/QueueConsumer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/enqueue/Consumption/QueueConsumer.php b/pkg/enqueue/Consumption/QueueConsumer.php index 19871599c..30d438dcd 100644 --- a/pkg/enqueue/Consumption/QueueConsumer.php +++ b/pkg/enqueue/Consumption/QueueConsumer.php @@ -299,7 +299,7 @@ private function onEnd(ExtensionInterface $extension, int $startTime, ?int $exit } /** - * The logic is similar to one in Symfony's ExceptionListener::. + * The logic is similar to one in Symfony's ExceptionListener::onKernelException(). * * https://github.com/symfony/symfony/blob/cbe289517470eeea27162fd2d523eb29c95f775f/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php#L77 */