From aafaf8963846acb0491a5082b08d08b5b713c23a Mon Sep 17 00:00:00 2001 From: "d.huethorst" Date: Tue, 27 Jun 2023 12:23:58 +0200 Subject: [PATCH 1/5] [TwigBridge] Fix for GitHub ticket 50789 Change the return type of AppVariable.php getSession from 'Session' to 'SessionInterface', to be in line with the return type of getSession in http-foundation/Request.php --- src/Symfony/Bridge/Twig/AppVariable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index 6cdbaa8370811..2d055d591cd80 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Session\Session; +use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\User\UserInterface; @@ -93,7 +93,7 @@ public function getRequest(): ?Request /** * Returns the current session. */ - public function getSession(): ?Session + public function getSession(): ?SessionInterface { if (!isset($this->requestStack)) { throw new \RuntimeException('The "app.session" variable is not available.'); From 7e04f589193ccbc79b785dec76dd856f28e352f7 Mon Sep 17 00:00:00 2001 From: "d.huethorst" Date: Tue, 27 Jun 2023 12:51:22 +0200 Subject: [PATCH 2/5] [TwigBridge] Fix for GitHub ticket 50789 Change the return type of AppVariable.php getSession from 'Session' to 'FlashBagAwareSessionInterface' --- src/Symfony/Bridge/Twig/AppVariable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index 2d055d591cd80..13acff7d1ee1e 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Session\SessionInterface; +use Symfony\Component\HttpFoundation\Session\FlashBagAwareSessionInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\User\UserInterface; @@ -93,7 +93,7 @@ public function getRequest(): ?Request /** * Returns the current session. */ - public function getSession(): ?SessionInterface + public function getSession(): ?FlashBagAwareSessionInterface { if (!isset($this->requestStack)) { throw new \RuntimeException('The "app.session" variable is not available.'); From 0d1d50bf5fa2cec78d69f86bb6cdc4ac1d0b2dc6 Mon Sep 17 00:00:00 2001 From: "d.huethorst" Date: Mon, 17 Jul 2023 10:17:51 +0200 Subject: [PATCH 3/5] [TwigBridge] Fix for GitHub ticket 50789 Change the return type of AppVariable.php getSession from 'Session' to 'SessionInterface' --- src/Symfony/Bridge/Twig/AppVariable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index 13acff7d1ee1e..2d055d591cd80 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Session\FlashBagAwareSessionInterface; +use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\User\UserInterface; @@ -93,7 +93,7 @@ public function getRequest(): ?Request /** * Returns the current session. */ - public function getSession(): ?FlashBagAwareSessionInterface + public function getSession(): ?SessionInterface { if (!isset($this->requestStack)) { throw new \RuntimeException('The "app.session" variable is not available.'); From 10fd572f30067c01445c10762ea3b25c1fd995a1 Mon Sep 17 00:00:00 2001 From: "d.huethorst" Date: Mon, 17 Jul 2023 10:54:33 +0200 Subject: [PATCH 4/5] [TwigBridge] Fix for GitHub ticket 50789 Change the return type of AppVariable.php getSession from 'Session' to 'SessionInterface' --- src/Symfony/Bridge/Twig/AppVariable.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index 2d055d591cd80..39ae66573ff9d 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -143,6 +143,10 @@ public function getFlashes(string|array $types = null): array return []; } + if (!method_exists($session, 'getFlashBag')) { + return []; + } + if (null === $types || '' === $types || [] === $types) { return $session->getFlashBag()->all(); } From 97fc164736dfb4f27954747129a8e5316a1c0023 Mon Sep 17 00:00:00 2001 From: "d.huethorst" Date: Mon, 17 Jul 2023 11:10:13 +0200 Subject: [PATCH 5/5] [TwigBridge] Fix for GitHub ticket 50789 Change the return type of AppVariable.php getSession from 'Session' to 'SessionInterface' --- src/Symfony/Bridge/Twig/AppVariable.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index 39ae66573ff9d..88612279d55ba 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -143,6 +143,8 @@ public function getFlashes(string|array $types = null): array return []; } + // In 7.0 (when symfony/http-foundation: 6.4 is required) this can be updated to + // check if the session is an instance of FlashBagAwareSessionInterface if (!method_exists($session, 'getFlashBag')) { return []; } 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