Skip to content

Commit 39ed8c0

Browse files
Merge branch '5.4' into 6.0
* 5.4: cs fix [Messenger] Fix Doctrine transport on MySQL [Filesystem] Remove needless `mb_*` calls [Translator] Fix translator overlapse [Yaml] Improve test coverage in DumperTest and ParserTest Extract dispatching console signal handling and include subscribers [Mailer] Fix error message in case of an STMP error [HttpClient] Fix shared connections not being freed on PHP < 8 [HttpFoundation] Fix invalid ID not regenerated with native PHP file sessions [HttpClient] Fix memory leak when using StreamWrapper minor: fix test [Serializer] Fix error message remove the ChatterInterface alias when the chatter service is removed Bump Symfony version to 5.4.12 Update VERSION for 5.4.11 Update CHANGELOG for 5.4.11 Bump Symfony version to 4.4.45 Update VERSION for 4.4.44 Update CONTRIBUTORS for 4.4.44 Update CHANGELOG for 4.4.44
2 parents 69302fb + 46c6ab3 commit 39ed8c0

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

Session/Storage/Handler/StrictSessionHandler.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ public function __construct(\SessionHandlerInterface $handler)
3030
$this->handler = $handler;
3131
}
3232

33+
/**
34+
* Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
35+
*
36+
* @internal
37+
*/
38+
public function isWrapper(): bool
39+
{
40+
return $this->handler instanceof \SessionHandler;
41+
}
42+
3343
public function open(string $savePath, string $sessionName): bool
3444
{
3545
parent::open($savePath, $sessionName);

Session/Storage/Proxy/SessionHandlerProxy.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy;
1313

14+
use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler;
15+
1416
/**
1517
* @author Drak <[email protected]>
1618
*/
@@ -22,7 +24,7 @@ public function __construct(\SessionHandlerInterface $handler)
2224
{
2325
$this->handler = $handler;
2426
$this->wrapper = $handler instanceof \SessionHandler;
25-
$this->saveHandlerName = $this->wrapper ? \ini_get('session.save_handler') : 'user';
27+
$this->saveHandlerName = $this->wrapper || ($handler instanceof StrictSessionHandler && $handler->isWrapper()) ? \ini_get('session.save_handler') : 'user';
2628
}
2729

2830
public function getHandler(): \SessionHandlerInterface

Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler;
16+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
1517
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
1618

1719
/**
@@ -159,6 +161,23 @@ public function testUpdateTimestamp()
159161

160162
$this->proxy->updateTimestamp('id', 'data');
161163
}
164+
165+
/**
166+
* @dataProvider provideNativeSessionStorageHandler
167+
*/
168+
public function testNativeSessionStorageSaveHandlerName($handler)
169+
{
170+
$this->assertSame('files', (new NativeSessionStorage([], $handler))->getSaveHandler()->getSaveHandlerName());
171+
}
172+
173+
public function provideNativeSessionStorageHandler()
174+
{
175+
return [
176+
[new \SessionHandler()],
177+
[new StrictSessionHandler(new \SessionHandler())],
178+
[new SessionHandlerProxy(new StrictSessionHandler(new \SessionHandler()))],
179+
];
180+
}
162181
}
163182

164183
abstract class TestSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface

0 commit comments

Comments
 (0)