Skip to content

Commit 1055c11

Browse files
Merge branch '3.4' into 4.4
* 3.4: [PropertyAccess] fix tests [WebProfilerBundle] fix test remove assertions that can never be reached [PropertyAccess] Improve message of unitialized property in php 7.4 [HttpFoundation] Fixed session migration with custom cookie lifetime [Serializer] Remove unused variable Allow URL-encoded special characters in basic auth part of URLs [Serializer] Fix unitialized properties (from PHP 7.4.2) when serializing context for the cache key [Validator] Add missing Ukrainian and Russian translations No need to reconnect the bags to the session Support for Content Security Policy style-src-elem and script-src-elem in WebProfiler [PropertyInfo][ReflectionExtractor] Check the array mutator prefixes last when the property is singular
2 parents 62f9250 + 940167f commit 1055c11

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Session/Storage/NativeSessionStorage.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ public function regenerate($destroy = false, $lifetime = null)
215215
return false;
216216
}
217217

218-
if (null !== $lifetime) {
218+
if (null !== $lifetime && $lifetime != ini_get('session.cookie_lifetime')) {
219+
$this->save();
219220
ini_set('session.cookie_lifetime', $lifetime);
221+
$this->start();
220222
}
221223

222224
if ($destroy) {
@@ -225,10 +227,6 @@ public function regenerate($destroy = false, $lifetime = null)
225227

226228
$isRegenerated = session_regenerate_id($destroy);
227229

228-
// The reference to $_SESSION in session bags is lost in PHP7 and we need to re-create it.
229-
// @see https://bugs.php.net/70013
230-
$this->loadSession();
231-
232230
if (null !== $this->emulateSameSite) {
233231
$originalCookie = SessionUtils::popSessionCookie(session_name(), session_id());
234232
if (null !== $originalCookie) {

Tests/Session/Storage/NativeSessionStorageTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,19 @@ public function testRegenerateDestroy()
120120
$this->assertEquals(11, $storage->getBag('attributes')->get('legs'));
121121
}
122122

123+
public function testRegenerateWithCustomLifetime()
124+
{
125+
$storage = $this->getStorage();
126+
$storage->start();
127+
$id = $storage->getId();
128+
$lifetime = 999999;
129+
$storage->getBag('attributes')->set('legs', 11);
130+
$storage->regenerate(false, $lifetime);
131+
$this->assertNotEquals($id, $storage->getId());
132+
$this->assertEquals(11, $storage->getBag('attributes')->get('legs'));
133+
$this->assertEquals($lifetime, ini_get('session.cookie_lifetime'));
134+
}
135+
123136
public function testSessionGlobalIsUpToDateAfterIdRegeneration()
124137
{
125138
$storage = $this->getStorage();

0 commit comments

Comments
 (0)
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