Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23f5070

Browse files
minor #36485 [Security] Fixed broken master build (wouterj)
This PR was merged into the 5.1-dev branch. Discussion ---------- [Security] Fixed broken master build | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | n/a The build failures are caused by these lines (line 100 specically): https://github.com/symfony/symfony/blob/2460ca59af71e0ce610a3f807ab092436850b487/src/Symfony/Component/Security/Http/Firewall/ContextListener.php#L97-L108 Since #34363, `$request->cookies->get()` is typehinted as `string|null`. On Travis with PHP=7.4, this doc typehint is transformed into PHP return type: `get(): ?string`. On tests, the session cookie is set to `true`. See #36118 for some background on why this is necessary. There are a couple possible solutions: 1. Update the `InputBag::get()` PHPdoc to use `@return scalar|null` 2. Use `$request->cookie->all()[$session->getName()]` in `ContextListener` 3. Allow pre-configuring the session ID in `MockArraySessionStorage`. I've implemented solution (1). The method is actually using `is_scalar()` to check if a deprecation notice should be triggered, so it is expected to return a scalar in Symfony 6. _I've had to update the `DebugClassLoader` to not convert this to `get(): ?scalar`, as that doesn't exists in PHP. I'm not sure if my changes are correct (but they work)._ Commits ------- 94f4763 Fixed fetching sessionId from InputBag
2 parents 2460ca5 + 94f4763 commit 23f5070

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Symfony/Component/Security/Http/Firewall/ContextListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ public function authenticate(RequestEvent $event)
9797
if (null !== $session) {
9898
$usageIndexValue = $session instanceof Session ? $usageIndexReference = &$session->getUsageIndex() : 0;
9999
$usageIndexReference = PHP_INT_MIN;
100-
$sessionId = $request->cookies->get($session->getName());
100+
$sessionId = $request->cookies->all()[$session->getName()] ?? null;
101101
$token = $session->get($this->sessionKey);
102102

103+
// sessionId = true is used in the tests
103104
if ($this->sessionTrackerEnabler && \in_array($sessionId, [true, $session->getId()], true)) {
104105
$usageIndexReference = $usageIndexValue;
105106
} else {

0 commit comments

Comments
 (0)