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) {
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: