Skip to content

Commit

Permalink
Merge pull request #776 from enumag/patch-2
Browse files Browse the repository at this point in the history
Fix exception loop in QueueConsumer
  • Loading branch information
makasim committed Feb 21, 2019
2 parents 499360e + 274aa0f commit ab32ca9
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions pkg/enqueue/Consumption/QueueConsumer.php
Expand Up @@ -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
*/
Expand All @@ -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;
}
Expand Down

0 comments on commit ab32ca9

Please sign in to comment.