From 5f5c6818971216517166654557cc0099fb596910 Mon Sep 17 00:00:00 2001 From: Edd Mann Date: Fri, 21 Sep 2018 17:14:51 +0100 Subject: [PATCH] Fix empty session value in Symfony adapter The mock session handler used within the tests takes the NULL value (if no cookie is present) and sets it as the id. This allows the subsequent check upon response to function correctly. However, when using the native session_id function in production, the NULL value is not returned and `session_id` returns an empty string. So as to meet these requirements we should instead replace NULL with an empty string to signify no session being present. --- src/Bridge/Symfony/SymfonyAdapter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bridge/Symfony/SymfonyAdapter.php b/src/Bridge/Symfony/SymfonyAdapter.php index 429d7a12d..a8a43a28d 100644 --- a/src/Bridge/Symfony/SymfonyAdapter.php +++ b/src/Bridge/Symfony/SymfonyAdapter.php @@ -48,14 +48,14 @@ public function handle(ServerRequestInterface $request): ResponseInterface return (new DiactorosFactory)->createResponse($symfonyResponse); } - private function loadSessionFromRequest(Request $symfonyRequest): ?string + private function loadSessionFromRequest(Request $symfonyRequest): string { if ($this->hasSessionsDisabled()) { - return null; + return ''; } $this->httpKernel->getContainer()->get('session')->setId( - $sessionId = $symfonyRequest->cookies->get(session_name()) + $sessionId = $symfonyRequest->cookies->get(session_name(), '') ); return $sessionId;