Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception loop in QueueConsumer #776

Merged
merged 2 commits into from Feb 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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