Closed joachim-n closed 1 year ago
That sounds like a great idea.
I was looking into this, and it might be hard.
\Drupal\Core\DependencyInjection\Compiler\StackedKernelPass
has logic that is specific to \Drupal\Core\StackMiddleware\StackedHttpKernel
However, I think we can decorate http_kernel.basic
which is Symfony\Component\HttpKernel\HttpKernel
.
From the StackedHttpKernel
$decorated_id = 'http_kernel.basic';
$middlewares_param = [new Reference($decorated_id)];
//...
$arguments = [$middlewares_param[0], $middlewares_param];
$stacked_kernel->setArguments($arguments);
Drupal's http_kernel service is StackedHttpKernel, which has $catch = TRUE.
That means that if the request throws an exception somewhere, the response 500 and you don't know why.
I'm wondering if it would be worth adding a testing_http_kernel which decorates the original service and sets $catch = FALSE. What do you think?