From 66648c51f1a568d6e9cf596d0c8b87ce0372d5ee Mon Sep 17 00:00:00 2001 From: Jordane Vaspard Date: Tue, 10 Oct 2023 13:26:09 +0200 Subject: [PATCH] [HttpKernel] Handle nullable callback of StreamedResponse --- src/Symfony/Component/HttpFoundation/StreamedResponse.php | 6 +++++- src/Symfony/Component/HttpKernel/HttpKernel.php | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/StreamedResponse.php b/src/Symfony/Component/HttpFoundation/StreamedResponse.php index 5c7817e3c9afd..37b6510b947d6 100644 --- a/src/Symfony/Component/HttpFoundation/StreamedResponse.php +++ b/src/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -56,8 +56,12 @@ public function setCallback(callable $callback): static return $this; } - public function getCallback(): \Closure + public function getCallback(): ?\Closure { + if (!isset($this->callback)) { + return null; + } + return ($this->callback)(...); } diff --git a/src/Symfony/Component/HttpKernel/HttpKernel.php b/src/Symfony/Component/HttpKernel/HttpKernel.php index 4999870e4c55d..d2cf4eaee27ce 100644 --- a/src/Symfony/Component/HttpKernel/HttpKernel.php +++ b/src/Symfony/Component/HttpKernel/HttpKernel.php @@ -92,8 +92,7 @@ public function handle(Request $request, int $type = HttpKernelInterface::MAIN_R } finally { $this->requestStack->pop(); - if ($response instanceof StreamedResponse) { - $callback = $response->getCallback(); + if ($response instanceof StreamedResponse && $callback = $response->getCallback()) { $requestStack = $this->requestStack; $response->setCallback(static function () use ($request, $callback, $requestStack) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy