Skip to content
Permalink
Browse files

Fix regression where exeptions from exec scripts weren't properly han…

…dled
  • Loading branch information
flack committed Nov 20, 2019
1 parent 3ddb269 commit ab8c9b5a2cd4d8dd633bea34839aa0b9fa1cf4fb
Showing with 16 additions and 0 deletions.
  1. +16 −0 src/midcom/httpkernel/subscriber.php
@@ -21,6 +21,8 @@
use midcom_connection;
use midcom_core_context;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
/**
* @package midcom.httpkernel
@@ -35,6 +37,7 @@ public static function getSubscribedEvents()
KernelEvents::REQUEST => ['on_request'],
KernelEvents::CONTROLLER_ARGUMENTS => ['on_arguments'],
KernelEvents::VIEW => ['on_view'],
KernelEvents::RESPONSE => ['on_response'],
KernelEvents::EXCEPTION => ['on_exception']
];
}
@@ -108,6 +111,19 @@ public function on_view(GetResponseForControllerResultEvent $event)
$event->setResponse(new midcom_response_styled($attributes->get('context')));
}
public function on_response(FilterResponseEvent $event)
{
if ($event->isMasterRequest()) {
$response = $event->getResponse();
if ($response instanceof StreamedResponse) {
// if we have a streamed response, we need to send right away
// otherwise exceptions in the callback won't be caught by the kernel
// which means e.g. that a midcom-exec script couldn't show a login screen
$response->send();
}
}
}
public function on_exception(GetResponseForExceptionEvent $event)
{
$handler = new \midcom_exception_handler();

0 comments on commit ab8c9b5

Please sign in to comment.
You can’t perform that action at this time.